I used codes below to init a root view controller
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[window addSubview:rootViewController.view];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController: rootViewController ];
}
it worked well on ios 4 about 2 years,ios5 1 years, there is no any problem when start to run the app
but on ios6 it crashed and reported
* Terminating app due to uncaught exception ‘UIViewControllerHierarchyInconsistency’, reason: ‘adding a root view controller as a child of view controller:’
Welcome any comment
‘rootViewController’ is already in your view hierarchy. Remove it from whatever other container its in (window.rootViewController ?) first (window.rootViewController = nil).