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

优化 首页的 手势交互

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