Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User interaction is disabled calling moveToViewController two times #284

Closed
ghost opened this issue Dec 7, 2016 · 5 comments
Closed

User interaction is disabled calling moveToViewController two times #284

ghost opened this issue Dec 7, 2016 · 5 comments

Comments

@ghost
Copy link

ghost commented Dec 7, 2016

When I call moveToViewController(at: Int, animated: Bool) or moveTo(viewController: UIViewController, animated: Bool) two consecutive times on the same index/ViewController the User interaction is disabled and the user is forced to close and reopen the app.

So I have to check each time that the index is not the same as the one currently displayed.

I suggest to edit moveToViewController(at: Int, animated: Bool) inside PagerTabStripViewController.swift adding currentIndex != index in the guard this way:

  open func moveToViewController(at index: Int, animated: Bool = true) {
        guard isViewLoaded && view.window != nil && currentIndex != index else {
            currentIndex = index
            return
        }
        if animated && pagerBehaviour.skipIntermediateViewControllers && abs(currentIndex - index) > 1 {
            var tmpViewControllers = viewControllers
            let currentChildVC = viewControllers[currentIndex]
            let fromIndex = currentIndex < index ? index - 1 : index   1
            let fromChildVC = viewControllers[fromIndex]
            tmpViewControllers[currentIndex] = fromChildVC
            tmpViewControllers[fromIndex] = currentChildVC
            pagerTabStripChildViewControllersForScrolling = tmpViewControllers
            containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: fromIndex), y: 0), animated: false)
            (navigationController?.view ?? view).isUserInteractionEnabled = false
            containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: true)
        } else {
            (navigationController?.view ?? view).isUserInteractionEnabled = false
            containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: animated)
        }
    }
@Maqix
Copy link
Contributor

Maqix commented Dec 9, 2016

1

Maqix added a commit to Maqix/XLPagerTabStrip that referenced this issue Dec 9, 2016
@Maqix Maqix mentioned this issue Dec 9, 2016
@Flox06
Copy link

Flox06 commented Dec 13, 2016

1

mtnbarreto pushed a commit that referenced this issue Jan 23, 2017
@carloscrono
Copy link

I think your fix didn't worked for me. When I call that method, the app stays frozen with no errors.

@pepejeria
Copy link

Using XLPagerTabStrip 7.0.0 and I am also getting the UI freeze. Anybody knows what is going on?

@pepejeria
Copy link

pepejeria commented May 5, 2017

Had to override moveToViewController to solve this issue

    open override func moveToViewController(at index: Int, animated: Bool = true) {
        containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: animated)
    }

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

No branches or pull requests

4 participants