ZYColumnViewController
ZYColumnViewController copied to clipboard
厉害了,谢谢哥们
大神。三克油
你的下面的页面视图是如何添加的
我下面对应的是一个collectionView,每个cell里面都是一个tableView。组件里面有三个代理方法 // 点击title 会回调到这里(点击的不是当前选中的才会回调,保证性能) func columnViewControllerSelectedTitle(selectedTitle: String, index: Int) { let indexPath = IndexPath(item: index, section: 0) self.collectionView?.scrollToItem(at: indexPath, at: .left, animated: true) }
// 滑动切换新闻列表会回调这里 (下面collectionView滑动了以后,给组件设置标题和指定当前索引 上面的组件内容就会跟着变化)
func columnViewControllerSetTitle(setTitle: String, index: Int) {
let indexPath = IndexPath(item: index, section: 0)
self.collectionView?.scrollToItem(at: indexPath, at: .left, animated: true)
}
// 频道内部排序,数量变化后回调
func columnViewControllerTitlesDidChanged(arrayTitles: [String]!, spareTitles: [String]?) {
// 归档用户订阅信息
UserDefaults.standard.set(arrayTitles, forKey: kUserColumnsTitles)
UserDefaults.standard.set(spareTitles, forKey: kUserColumnsSpareTitles)
UserDefaults.standard.synchronize()
arrayShowTitles = arrayTitles
synchronizeModel() // 同步模型数据
handleTableViewVCs(titles: arrayTitles)
}
// scrollView 代理方法 做一些索引的处理 就差不多了 func scrollViewDidScroll(_ scrollView: UIScrollView) { let page = scrollView.contentOffset.x/scrollView.frame.width currentIndex = lroundf(Float(page)) }
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let selTitle = arrayShowTitles[currentIndex]
columnVC?.setSelectItem(title: selTitle)
lastIndex = currentIndex
}