Crash when using someviewinsidestack.hidden = true
GlaucoNeves opened this issue · 3 comments
I'm getting a crash when I'm trying to hide some of my views from the stack. I tried to remove two different views from my stack, one that doesn't have constraints inside, and another that does. The first one hides normally, the second one causes my application to crash. I'm using SnapKit to set contraints and I'm still using Swift 1.2.
I don't have time to provide more details now. Later today I'm going to try to reproduce this error in the demo app, then I'll post an update.
Thanks.
What version of TZStackView are you using? And can you send me a report of the crash?
I'm using the 1.0.0 version.
I created a repository with the code that reproduces the issue: https://github.com/GlaucoNeves/TZStackViewIssue
I also tried the same code in Xcode 7 using the UIStackView and the vertical constraints in my custom view conflict, then the iOS break one of them and can continue without crash the app.
The crash report (you need to change the extension to .crash):
@GlaucoNeves I was seeing a similar issue due to AutoLayout constraint errors/conflicts when hiding an auto-height view with top and bottom constraints relative its subviews. I worked around this issue by storing a reference to the bottom layout constraint, then removing or adding it based on the view's hidden
value:
override var hidden: Bool {
didSet {
// need to remove bottom constraint for auto-height layout else we'll get AutoLayout errors
bottomLayoutConstraint?.active = !hidden
}
}
private var bottomLayoutConstraint: NSLayoutConstraint?