Change window's rootViewController at runtime
Change window's rootViewController at runtime
- Subject: Change window's rootViewController at runtime
- From: Diederik Meijer <email@hidden>
- Date: Wed, 29 Jul 2015 14:35:10 +0200
Did my message below get posted yesterday? I see no replies and did get a weird spam response.
Dear list,
I am working on an iOS app that uses a UISplitViewController.
As per the client’s requirements, a UIViewController should be loaded before the UISplitViewController loads.
This “preceding” UIViewController - let’s call it the Home Screen - allows the user to select from a small number of content packages, the selection is used to populate the UISplitViewControllers’s view controllers.
Obviously, the Home Screen must be loaded before or at the same time the splitview becomes visible, the splitview must not be visible before the Home Screen becomes visible.
In a previous project I worked around this by calling presentViewController in the UISplitViewController’s viewController that populates the splitview’s detail section, setting animated to NO.
However, this triggers warnings that indicate that the presenting viewController tries to present a viewController while a presentation is in progress. This indicates the system wants to be done with loading the splitView and laying out is subviews, before one of its subviews can call presentViewController to load the Home Screen.
In a current project I am taking a different approach, as follows:
At application launch both the UISplitViewController and the “preceding” UIViewController are both instantiated as properties of the AppDelegate and the “preceding” UIViewController is initially set as the app delegate window’s rootViewController. The app now launches immediately into the Home Screen, not being called from any other ViewController.
After user selection, a method is called in the app delegate that replaces the window’s rootViewController, setting it to the UISplitViewController. At the same time, the UISplitViewController’s ViewControllers in master and detail get the information needed to get the data they need to populate their views.
This works fine and I get no warnings or errors.
However, since it is the first time I am taking this approach I would like to double check if I am overlooking any issues. In short, is this approach acceptable? Or are there any risks to it?
Many thanks,
Diederik
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden