【问题标题】:Custom Navigation controller in Storyboard故事板中的自定义导航控制器
【发布时间】:2015-04-19 05:38:48
【问题描述】:

在其中我正在创建自定义导航控制器,并且我将视图作为情节提要,但该视图未加载

 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

//create the navigation controller and add the controllers view to the window
_navigationController = [[UINavigationController alloc] init];
[self.window addSubview:[self.navigationController view]];

//check if the first viewcontroller eixsts, otherwise create it
if(self.firstViewController == nil)
{
    ViewController *firstView = (ViewController *)[mainStoryBoard instantiateViewControllerWithIdentifier:@"mainView123"];
   // ViewController *firstView = [[ViewController alloc] init];
    self.firstViewController = firstView;
}

//push the first viewcontroller into the navigation view controller stack
[self.navigationController pushViewController:self.firstViewController animated:YES];

self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

【问题讨论】:

  • 你的根视图控制器是什么?您是否将导航控制器设置为根?
  • 如果你正确使用故事板,你应该不需要这个。

标签: ios objective-c xcode-storyboard


【解决方案1】:

首先您应该将导航设置为rootviewcontroller,然后尝试这样的操作。

 UIStoryboard *storyboard =[UIStoryboardstoryboardWithName:@"MainStoryboard_iPhone" bundle:nil];
    MyNewViewController *myVC = (MyNewViewController *)[storyboard    instantiateViewControllerWithIdentifier:@"myViewCont"];
     self.firstViewController = myVc;

【讨论】:

    猜你喜欢
    • 2012-03-10
    • 1970-01-01
    • 2013-01-10
    • 2018-04-09
    • 2013-02-03
    • 1970-01-01
    • 2015-05-31
    • 2012-01-22
    • 2014-06-26
    相关资源
    最近更新 更多