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

XLPagerTabStrip crashing when self.view.layoutIfNeeded() is called #312

Closed
RyanHop3 opened this issue Jan 31, 2017 · 4 comments
Closed

XLPagerTabStrip crashing when self.view.layoutIfNeeded() is called #312

RyanHop3 opened this issue Jan 31, 2017 · 4 comments

Comments

@RyanHop3
Copy link

RyanHop3 commented Jan 31, 2017

When submitting issues, please provide the following information to help maintainers to fix the problem faster:

  • Environment: XLPagerTabStrip 7.0, XCode 8.2.1, Swift 3

In the viewDidLoad of the XLPagerTabStrip View Controller I have tried to call self.view.layoutIfNeeded() which is causing the simulator to crash on:

let fromFrame = layoutAttributesForItem(at: IndexPath(item: fromIndex, section: 0))!.frame
within the open func move from the buttonBarView class.

@fdocr
Copy link

fdocr commented Feb 3, 2017

I had a similar issue using same Xcode & Swift version (XLPagerTabStrip ~> 7.0). The following worked in my case, it might help:

I implemented ButtonBarPagerTabStripViewController without IB, i.e. without setting up an IBOutlet to a view. My crash was caused by the buttonBarView not being retained. Kind of a special implementation (whose isn't?) where I removed the buttonBarView from the ViewController's view and manually added to the navigationBar.

Tried a few different solutions but ended up declaring a dummy variable to force the retain:

...

var buttonBarViewRetainer: UIView?

...


override func viewDidLoad() {
 
     ...

    // This will retain the buttonBarView (declared as weak) to avoid optional unwrapping crash
    buttonBarViewRetainer = buttonBarView
   
    // Custom configuration as used to work before Swift 3.0 migration
    buttonBarView.removeFromSuperview()
     ...

}

@santiagofm
Copy link
Contributor

This issue is addressed in #375 and should be merged into the master branch shortly.

@santiagofm
Copy link
Contributor

Fixed in #380

@Tim77277
Copy link

Sorry, I just pulled the latest version and I still ran into the same problem. I went through the #375, #380 but still not be able to solve this issue. Can use some helps here if anyone can give some advise thanks.

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

No branches or pull requests

4 participants