How to jump among UIViewControllers?
A upcoming iPhone app will comes with about 20 UIViewController
s which does not have any hierarchical relationship amon开发者_开发百科g them. Potentially any UIViewController
can/will jump to another UIViewController
. What is the best way to handle the switching among UIViewController
s for this app? Thanks!
You'll need another object to manage all the view controllers. This can be your app delegate, or it can be an object dedicated to managing views. Depending on how your app works, you may want to create another managing ViewController to present specific views in a manner similar to a UITabBarController or a UINavigationController. In this case, each of your 20 UIViewControllers will have their views presented as a subview of the managing ViewController.
Use a table to select which one to go to. Pretty much the only view that can handle a selection of 20 elements without getting awkward.
You can use NSMutableArray to maintain those UIViewControllers. A sample codes I studied keep 3 UIViewControllers normally, and assign [NSNull null] into array for those freed or un-loaded UIViewControllers. UINavigationController is convenient, and it maintains its viewControllers by array too.
精彩评论