I'm writing unit tests for a bunch of view controllers hooked up with segues in a storyboard. The initial view controller is a UINavigationController
.
I was interested in testing that a button in the topViewController
, once tapped, performed some action (e.g. it invoked a method on a mock, for instance).
This requires the UINavigationController
and its children to be loaded into the view hierarchy first.
I learned from at least two sources that you can call the viewController's beginAppearanceTransition:animated:
is recommended by both:
The trouble is, when you invoke beginAppearanceTransition:animated:
on a UINavigationController
, the lifecycle methods (viewDidLoad
, viewWillAppear:
, viewDidAppear:
etc.) don't get invoked for the topViewController
.
That's really strange, because you'd think that loading the view of the navigation controller would necessarily require the top view controller to be loaded as well.
What can be done about this? My current workaround is just to load the view of the top view controller directly; but this is not ideal.
Aucun commentaire:
Enregistrer un commentaire