【问题标题】:UINavigationcontroller initWithRootViewController from appDelegate, empty view?来自appDelegate的UINavigationcontroller initWithRootViewController,空视图?
【发布时间】:2011-02-18 10:19:11
【问题描述】:

我遇到了问题。

我想用 UIViewController 初始化 UINavigationcontroller。当我的 Viewcontroller 从我正在使用的 .xib 加载时

UINavigationController *myNavigationController = [[UINavigationController alloc] initWithRootViewController:appDelegate.myViewController];

[self presentModalViewController:myNavigationController Animation:YES];

很遗憾,我的观点是空的。

我做错了什么还是有其他方法可以实现我的目标?

如果我像这样分配我的 Viewcontroller 的实例

UIViewController *aController = [[UIViewController alloc] initWithNibName:@"myViewController" bundle:[NSBundle mainBundle]];

并且在笔尖内有一个按钮,我的应用程序在点击它时会崩溃。

非常感谢。

【问题讨论】:

    标签: iphone delegates uiviewcontroller uinavigationcontroller


    【解决方案1】:

    myViewController *aController = [[myViewController alloc] initWithNibName:@"myViewController" bundle:[NSBundle mainBundle]];

    UIViewController *aController = [[myViewController alloc] initWithNibName:@"myViewController" bundle:[NSBundle mainBundle]];

    然后推一下

    因为

    如果你这样输入

    UIViewController *aController = [[UIViewController alloc] initWithNibName:@"myViewController" bundle:[NSBundle mainBundle]];

    你正在分配 UIViewController 并且不知道你在默认 UIViewcontroller 中的按钮

    这意味着没有 UIButton 属性。

    所以它崩溃了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-15
      • 2013-04-19
      • 1970-01-01
      • 2011-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多