Pager
Pager copied to clipboard
How to stop scrolling from left if we are at index 0.(Bouncing)
How can we stop scrolling from left if we are at index 0 and stop scrolling from right if we are at last index. I tried :- @lucoceano
override func scrollViewDidScroll(_ scrollView: UIScrollView) {
if currentIndex == 0 && scrollView.contentOffset.x < scrollView.bounds.size.width {
scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
} else if currentIndex == (viewControllers.count - 1) && scrollView.contentOffset.x > scrollView.bounds.size.width {
scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
}
//reloadData()
}
override func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
if currentIndex == 0 && scrollView.contentOffset.x < scrollView.bounds.size.width {
scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
} else if currentIndex == (viewControllers.count - 1) && scrollView.contentOffset.x > scrollView.bounds.size.width {
scrollView.contentOffset = CGPoint(x: scrollView.bounds.size.width, y: 0)
}
}
Not working. Thanks
So for what I understood you just wanna stop bouncing? Please take a look at this
I tried the same but when click on a tab, it's giving an exception. I don't know how can I resolve it. Please tell me if click on a tab also how we can change the tab indicator and index? @lfarah @lucoceano Thanks
What exception? Please post some code here
Exception :- 'Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No view controller managing visible view <UIView: 0x7fc3ad90ed70; frame = (0 0; 320 458); autoresize = W+H; layer = <CALayer: 0x60800003dda0>>'
Even tab indicator is also not updating. Code you can see in my question. @lfarah @lucoceano Thanks