2012-10-30 64 views
0

我需要卸載故事板並用另一個視圖控制器替換根視圖控制器。當我完成另一個視圖控制器時,我需要卸載他並恢復故事板和根視圖控制器。當我嘗試替換根視圖控制器時,故事板仍與其他視圖一起存在。如何卸載故事板?

回答

1
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{ 
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:DesiredViewController]; 
} 

,當你想要的故事板到desiredViewController接手後..

使用的代碼在desiredViewController

AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate]; 
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; //MainStoryBoard is the name of your storyBorad 
     UIViewController* myStoryBoardInitialViewController = [storyboard instantiateInitialViewController]; 

     [appDelegate.window setRootViewController:myStoryBoardInitialViewController ];