Open ghost opened 8 years ago
Its more like tinder style atm
Thanks for the great project, I have used EZSwipeController successfully in my own project, which has three viewcontrollers and the left most one is for message and the right most one is for system setting, so it's important for me to disable scrolling when it's in message or setting sections, because otherwise it's quite ugly. I successfully achieved this by implementing the delegate of UIScrollViewDelegate as
extension MySwipeVC: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if self.currentVCIndex == 0 && (scrollView.contentOffset.x < scrollView.bounds.size.width) {
scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
} else if self.currentVCIndex == self.stackVC.count - 1 && (scrollView.contentOffset.x > scrollView.bounds.size.width) {
scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
}
}
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
if self.currentVCIndex == 0 && (scrollView.contentOffset.x < scrollView.bounds.size.width) {
scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
} else if self.currentVCIndex == self.stackVC.count - 1 && (scrollView.contentOffset.x > scrollView.bounds.size.width) {
scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
}
}
}
And in viewWillAppear, I added
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
for someview in self.pageViewController.view.subviews {
if someview is UIScrollView {
let scrollview = someview as! UIScrollView
scrollview.delegate = self
}
}
}
To make this actually work, in EZSwipeController, it should update currentStackVC after pageViewController completed setViewControllers, I have made a PR in case other people need the same feature as I.
@liyukuang did you by any chance initialize a UITableViewController in the EZSwipeController? I opened a similar issue because I have an array of objects (n) that sorts out which UITableViewController to show. But is it even possible to initialize multiple, and unknown numbers of UITableViewControllers in this???
It will be nicer if we can disable the scroll to make it more like snapchat style.