Pager icon indicating copy to clipboard operation
Pager copied to clipboard

How to stop scrolling from left if we are at index 0.(Bouncing)

Open kishor010 opened this issue 8 years ago • 4 comments

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

kishor010 avatar Jan 31 '17 13:01 kishor010

So for what I understood you just wanna stop bouncing? Please take a look at this

lfarah avatar Feb 07 '17 00:02 lfarah

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

kishor010 avatar Feb 13 '17 05:02 kishor010

What exception? Please post some code here

lfarah avatar Feb 14 '17 20:02 lfarah

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

kishor010 avatar Feb 15 '17 04:02 kishor010