[英]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. 我创建了一个SingleView应用程序,然后使用“嵌入导航控制器”来获取导航控件。 when push a controller, the viewcontroller's backgroundColor is black.
按下控制器时,viewcontroller的backgroundColor为黑色。
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?
只设置viewcontroller的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];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.