Commit 44205b7a authored by David黄金龙's avatar David黄金龙

优化 首页的 手势交互

parent 9d7d3720
......@@ -19,8 +19,6 @@ class ContentBaseViewController: UIViewController {
}
}
weak var myParentVC : YHHomeViewController?
let arrItemTitles = ["推荐","子女教育","税务规划","民生医疗","成功案例","我的服务","行业资讯","香港生活","你我他","我是很长的tag呀"]
......@@ -46,16 +44,11 @@ class ContentBaseViewController: UIViewController {
//分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = {
return JXSegmentedListContainerView(dataSource: self)
return JXSegmentedListContainerView(dataSource: self, type: .collectionView)
}()
override func viewDidLoad() {
super.viewDidLoad()
listContainerView.backgroundColor = .purple//for test hjl
listContainerView.scrollView.backgroundColor = .red //for test hjl
for _ in arrItemTitles {
let vc = YHDavidTestViewController()
......@@ -103,23 +96,12 @@ class ContentBaseViewController: UIViewController {
segmentedView.frame = CGRect(x: 0, y: 0, width: view.bounds.size.width, height: 50)
listContainerView.frame = CGRect(x: 0, y: 50, width: view.bounds.size.width, height: view.bounds.size.height - 50)
// view.backgroundColor = .purple//for test hjl
}
}
extension ContentBaseViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
// self.myParentVC?.tableViewCanScrollFlag = true
}
func segmentedView(_ segmentedView: JXSegmentedView, didScrollSelectedItemAt index: Int) {
printLog("hjl- didScrollSelectedItemAt ")
// self.myParentVC?.tableViewCanScrollFlag = true
NotificationCenter.default.post(name: Notification.Name(rawValue: "scrollViewDidEndDragging"), object: nil)
}
/// 正在滚动中的回调
......@@ -130,8 +112,7 @@ extension ContentBaseViewController: JXSegmentedViewDelegate {
/// - rightIndex: 正在滚动中,相对位置处于右边的index
/// - percent: 从左往右计算的百分比
func segmentedView(_ segmentedView: JXSegmentedView, scrollingFrom leftIndex: Int, to rightIndex: Int, percent: CGFloat) {
printLog("hjl- scrollingFrom [\(percent)] leftIndex=\(leftIndex) rightIndex=\(rightIndex)")
// self.myParentVC?.tableViewCanScrollFlag = false
NotificationCenter.default.post(name: Notification.Name(rawValue: "scrollViewWillBeginDragging"), object: nil)
}
}
......
......@@ -110,11 +110,7 @@ class YHDavidTestViewController: YHBaseViewController {
gk_navigationBar.isHidden = true
self.items = [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高")]
self.items = [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高")]
// self.myCollectView.es.stopPullToRefresh(ignoreDate: true,ignoreFooter: false)
self.myCollectView.reloadData()
......@@ -127,11 +123,7 @@ extension YHDavidTestViewController {
private func loadFirstItem() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.items = [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"),
AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高")]
self.items = [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高")]
self.myCollectView.es.stopPullToRefresh(ignoreDate: true,ignoreFooter: false)
self.myCollectView.reloadData()
}
......@@ -141,11 +133,7 @@ extension YHDavidTestViewController {
private func loadFakeData() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高"))
self.myCollectView.es.stopLoadingMore()
self.myCollectView.reloadData()
}
......
......@@ -21,7 +21,7 @@ class YHHomeViewController: YHBaseViewController {
var myCellHeight : CGFloat {
get {
return view.bounds.size.height - homeNavBarView.height - k_TabBar_Height - k_Height_NavigationtBarAndStatuBar - cellHeight * 2
return view.bounds.size.height - homeNavBarView.height - k_TabBar_Height
}
}
......@@ -87,9 +87,9 @@ class YHHomeViewController: YHBaseViewController {
tableView.separatorStyle = .none
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 100
tableView.register(YHHomeCustomCell.self, forCellReuseIdentifier: YHHomeCustomCell.cellReuseIdentifier)
// tableView.rowHeight = UITableView.automaticDimension
// tableView.estimatedRowHeight = 100
// tableView.register(YHHomeCustomCell.self, forCellReuseIdentifier: YHHomeCustomCell.cellReuseIdentifier)
tableView.register(YHDavidCell0.self,forCellReuseIdentifier: YHDavidCell0.cellReuseIdentifier)
tableView.register(YHDavidCell1.self,forCellReuseIdentifier: YHDavidCell1.cellReuseIdentifier)
......@@ -124,16 +124,15 @@ class YHHomeViewController: YHBaseViewController {
// MARK: - 生命周期方法
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(leaveTopOp), name:Notification.Name(rawValue: "leaveTop"), object: nil)
// NotificationCenter.default.addObserver(self, selector: #selector(beginDragging), name:Notification.Name(rawValue: "scrollViewWillBeginDragging"), object: nil)
//
//
// NotificationCenter.default.addObserver(self, selector: #selector(endDragging), name:Notification.Name(rawValue: "scrollViewDidEndDragging"), object: nil)
// cellView.myParentVC = self
NotificationCenter.default.addObserver(self, selector: #selector(beginDragging), name:Notification.Name(rawValue: "scrollViewWillBeginDragging"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(endDragging), name:Notification.Name(rawValue: "scrollViewDidEndDragging"), object: nil)
//1.UI
initView()
......@@ -152,22 +151,17 @@ class YHHomeViewController: YHBaseViewController {
extension YHHomeViewController {
@objc func leaveTopOp() {
print("leaveTopOp")
canScroll = true
}
@objc func beginDragging() {
print("beginDragging")
homeTableView.isScrollEnabled = false
canScroll = false
cellView.canScroll = false
}
@objc func endDragging() {
print("endDragging")
homeTableView.isScrollEnabled = true
canScroll = true
cellView.canScroll = true
}
......@@ -209,7 +203,7 @@ extension YHHomeViewController {
homeTableView.dataSource = self
view.addSubview(homeTableView)
homeTableView.snp.makeConstraints { make in
make.top.equalTo(homeNavBarView.snp.bottom).offset(5)
make.top.equalTo(homeNavBarView.snp.bottom).offset(0)
make.left.right.bottom.equalToSuperview()
}
......@@ -341,7 +335,7 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource {
let cell = UITableViewCell()
cellView.view.frame = CGRect(x: 0, y: 0, width: cell.contentView.bounds.size.width, height: KScreenHeight - 64)
cellView.view.frame = CGRect(x: 0, y: 0, width: cell.contentView.bounds.size.width, height: myCellHeight)
cell.contentView.addSubview(cellView.view)
return cell
}
......@@ -366,6 +360,11 @@ extension YHHomeViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
// if scrollView.isScrollEnabled == false {
// printLog("Main scrollView.isScrollEnabled == false")
// return
// }
if scrollView === homeTableView {
let bottomCellOffset: CGFloat = homeTableView.rect(forSection: 1).origin.y - 64 + 80 - 12 //48
printLog("Main scrollView.contentOffset.y = \(scrollView.contentOffset.y) bottomCellOffset= \(bottomCellOffset)")
......
......@@ -49,7 +49,6 @@ class YHBbxCollectionViewCell: UICollectionViewCell {
private func setupUI() {
// contentView.backgroundColor = .brown //for test hjl
contentView.addSubview(titleImageView)
titleImageView.snp.makeConstraints { make in
make.top.equalToSuperview()
......
......@@ -109,10 +109,7 @@ class YHDavidCell5: UITableViewCell {
collectinoView.alwaysBounceVertical = true
myCollectView = collectinoView
myCollectView.isScrollEnabled = false
// myCollectView.backgroundColor = .red //for test hjl
// myCollectView.backgroundColor = UIColor(hex:0xff0000)
subContentView.addSubview(myCollectView)
myCollectView.snp.makeConstraints { make in
make.top.equalTo(bbxLable.snp.bottom).offset(15)
......
......@@ -42,8 +42,6 @@ class YHHomeCustomCell: UITableViewCell {
collectionView.backgroundColor = UIColor.white
collectionView.register(YHAboutUsAdvantageCell.self, forCellWithReuseIdentifier:YHAboutUsAdvantageCell.cellReuseIdentifier)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.backgroundColor = .yellow //for test hjl
collectionContainer = UIView(frame: .zero)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment