-
Notifications
You must be signed in to change notification settings - Fork 7
Certain view configurations can cause center button constraints to disappear #16
Comments
@dodgecm So you're saying this is as opposed to the current button auto layout constraints that bind against the if #available(iOS 11.0, *) {
NSLayoutConstraint.activate([
button.centerXAnchor.constraint(equalTo: view.centerXAnchor),
button.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
button.widthAnchor.constraint(equalToConstant: unselectedImage.size.width),
button.heightAnchor.constraint(equalToConstant: unselectedImage.size.height)
])
} else { To replace the above with your suggestion? Or are you suggesting that this work with the button constraints need to be applied and reapplied, because the tab bar gets blown away? Also, just to be totally clear: when you say "wrap a tab controller around a navigation controller" are you saying the parent VC is the tab controller and a nav controller is embedded within the tab controller? Or that the parent is a nav controller and you're embedding a tab controller within the nav controller? I'm assuming the former (since I don't think you can even do the latter), but I just want to make 100% sure I'm clearly understanding you. |
@hsoi Yes, I'm suggesting that binding the constraints against the tabBar (instead of the TabBarVC) is a better solution; you could also try to detect when the constraints are getting disabled and try to re-enable them, but I tried that first and had a lot of difficulty getting it to work. And yes, I meant the former. I have a Tab Controller, and then one of the tabs is a Nav controller. Pushing a view that has Hides Bottom Bar on Push set onto that Nav controller will trigger the issue. If my explanation is unclear, I suggest checking out the example I linked in the original comment, since that project reproduces the bug within your demo app. |
@dodgecm OK. Hrm. Yeah, I could see that constraining vs. the tab bar is actually the more semantically correct way to go, since this is about "replacing/overriding" the tab. If you could make a pull-request, that'd be the fastest way to get this all done and integrated. Else I'll get to it as soon as I can. |
@hsoi Do you plan on supporting below iOS 9.0? If so I can just set up a PR for my solution. Otherwise I'll have to figure out how to make it work with the legacy constraint API too. |
@dodgecm that's fine. Frankly with iOS 11 out. I'm even OK if iOS 10 becomes the minimum. |
I ran into this doozy of an issue when setting "Hides Bottom Bar on Push" in one of my view controllers. When you wrap a tab controller around a navigation controller, and then push a VC with that setting onto the nav controller, Apple will helpfully completely unmount the tab bar from the view stack for a moment, and in doing so nuking the layout constraints on the center button.
I modified the storyboard in your example app to reproduce the issue.
I also took a stab at fixing it; this solution works for anything above iOS 9.0. I don't support below that in my own app, so I didn't try to fix the legacy autolayout contraint use case.
The text was updated successfully, but these errors were encountered: