简体   繁体   中英

why use storyboard push a viewcontroller shows black screen

I created a SingleView application then use "Embed In Navigation Controller" to get a navigation control. when push a controller, the viewcontroller's backgroundColor is black.

i know use this code :

UIStoryboard * storyBoard  =  [UIStoryboard storyboardWithName:@"Main" bundle:nil];//UIStoryboard(name: "Main", bundle:nil)
UIViewController *roomController = [storyBoard instantiateViewControllerWithIdentifier:@"controlerID"];

but what's the reason ? and if i don't want to use the storyboard completely ,only use this code

 UIViewController *roomController = [[UIViewController alloc]init];

what can i do? is only set the viewcontroller's backgroundColor?

您需要使用instantiateViewControllerWithIdentifier :你的方法UIStoryboard实例,然后你可以把控制器。

UIStoryboard *storyboard =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *roomController = [storyboard instantiateViewControllerWithIdentifier:@"controlerID"];
[self.navigationController pushViewController: roomController animated:YES];

// if You make controller with out storyboard Than change You view color

UIViewController *roomController = [[UIViewController alloc]init];
[self.navigationController pushViewController: roomController animated:YES];

- (void)viewDidLoad 
{
  self.view.backgroundColor =[UIColor whiteColor];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM