QuickBirdEng / XCoordinator

🎌 Powerful navigation library for iOS based on the coordinator pattern
MIT License
2.26k stars 177 forks source link

When triggering a `.push` transition, the `navigationController` property of the presented viewController isn't set in time #196

Closed SwiftedMind closed 4 years ago

SwiftedMind commented 4 years ago

Hey,

loving this framework so far :D. I do have one problem with it, though.

When pushing a new view controller in a UINavigationController the traditional way, the presented view controller's navigationController property is set pretty fast and already accessible inside the viewDidLoad() method to set things like prefersLargeTitle and stuff.

However, when using a NavigationCoordinator with a .push transition, the navigationController isn't set that early. It's only available by the time viewWillAppear(animated:) is called and that seems to be too late for some things, like setting: navigationController?.navigationBar.prefersLargeTitles = true

At least, it doesn't show a large title this way (only after scrolling up and down a bit it updates to a proper large title).

Is there something I can do? Any idea why the navigationController property is set so late in the process?

Thanks!

Let me know if you need more information. I don't know what else would be needed to clarify this. If you need an example, open the XCoordinator-Example app and set a breakpoint in the AboutViewController's viewDidLoad method. In there, navigationController is not set yet, which is a problem I think

pauljohanneskraft commented 4 years ago

Hey @d3mueller,

the reason for this is that we are calling loadViewIfNeeded before we are actually showing the view, because we would like to create all the bindings with views created out of IBOutlets, that are only instantiated when loading the view. So, if it is an issue at all, it would only be limited to the example app and not the framework itself.

Let me know, if you notice any actual issues with it, since you could also already set the prefersLargeTitles property when initializing the UINavigationController instead of the viewDidLoad of one of its child view controllers.

SwiftedMind commented 4 years ago

Hey, thanks for the quick answer!

Yeah, that makes sense. I have actually not thought about setting the prefersLargeTitle inside the Coordinator, thanks for the tip! That should work perfectly fine in my case.

Appreciate the help :)

pauljohanneskraft commented 4 years ago

Alright, since it seems to have fixed the issue, I will close it. Glad I could help!