[英]How to unload view and recreate it using storyboard when didReceiveMemoryWarning
[英]How to unload storyboard?
我需要卸載情節提要,並用另一個視圖控制器替換根視圖控制器。 當我完成另一個視圖控制器的操作后,我需要卸載他並還原情節提要和根視圖控制器。 當我嘗試替換根視圖控制器時,情節提要仍與其他視圖一起使用。
在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:DesiredViewController];
}
以及當您希望StoryBoard接管所需的ViewController之后。
使用所需的ViewController中的代碼
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 ];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.