![](/img/trans.png)
[英]when i push viewcontroller in navigation controller, shows black screen - empty view
[英]why use storyboard push a viewcontroller shows black screen
我創建了一個SingleView應用程序,然后使用“嵌入導航控制器”來獲取導航控件。 按下控制器時,viewcontroller的backgroundColor為黑色。
我知道使用此代碼:
UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];//UIStoryboard(name: "Main", bundle:nil)
UIViewController *roomController = [storyBoard instantiateViewControllerWithIdentifier:@"controlerID"];
但是是什么原因呢? 如果我不想完全使用情節提要,請僅使用此代碼
UIViewController *roomController = [[UIViewController alloc]init];
我能做什么? 只設置viewcontroller的backgroundColor?
您需要使用instantiateViewControllerWithIdentifier
:你的方法UIStoryboard
實例,然后你可以把控制器。
UIStoryboard *storyboard =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *roomController = [storyboard instantiateViewControllerWithIdentifier:@"controlerID"];
[self.navigationController pushViewController: roomController animated:YES];
//如果您使控制器沒有情節提要而不是更改,則您將查看顏色
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.