简体   繁体   English

为什么使用情节提要板推视图控制器显示黑屏

[英]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.

相关问题 当我在导航控制器中按ViewController时,显示黑屏-空视图 - when i push viewcontroller in navigation controller, shows black screen - empty view Xcode 5 Storyboard-presentViewController不呈现我现有的Viewcontroller并显示黑屏 - Xcode 5 Storyboard - presentViewController not presenting my existing Viewcontroller and giving black screen 情节提要ViewController的自定义类设置为不带有Xib的ViewController时显示黑色 - Storyboard viewcontroller's custom class set as a viewcontroller without xib shows black 在实现rootviewcontroller之后,Viewcontroller只会显示黑屏 - Viewcontroller just shows black screen after implementing a rootviewcontroller 当前视图显示黑屏,为什么? - Present view shows black screen, why? 使 SwiftUI 视图嵌入在 Storyboard 视图控制器中使用全屏宽度 - Make SwiftUI View embedded in Storyboard ViewController use full Screen Width 使用Storyboard时不通过Storyboard推送ViewController - Push a ViewController not through Storyboard while working with Storyboard pushViewController导致黑屏,无故事板 - pushViewController lead to black screen, NO STORYBOARD 使用Storyboard和Xib用于同一ViewController? - use Storyboard and xib for same viewcontroller? iOS - 从代码和故事板推送viewController - iOS - Push viewController from code and storyboard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM