Change window.rootViewController at runtime
Change window.rootViewController at runtime
- Subject: Change window.rootViewController at runtime
- From: Diederik Meijer <email@hidden>
- Date: Tue, 28 Jul 2015 14:36:14 +0200
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.
In a current project I am taking another 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 update their data.
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?
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