Skip to content
This repository has been archived by the owner on Jun 24, 2020. It is now read-only.

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

Open
kishor010 opened this issue Jan 31, 2017 · 4 comments
Open

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

kishor010 opened this issue Jan 31, 2017 · 4 comments

Comments

@kishor010
Copy link

kishor010 commented Jan 31, 2017

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 kishor010 changed the title How to stop scrolling from left if we are at index 0. How to stop scrolling from left if we are at index 0.(Bouncing) Feb 1, 2017
@lfarah
Copy link
Collaborator

lfarah commented Feb 7, 2017

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

@kishor010
Copy link
Author

kishor010 commented Feb 13, 2017

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

@lfarah
Copy link
Collaborator

lfarah commented Feb 14, 2017

What exception? Please post some code here

@kishor010
Copy link
Author

kishor010 commented Feb 15, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants