【发布时间】:2012-05-05 14:48:53
【问题描述】:
我想显示一个来自 xib 的模式对话框。显示我的窗口的代码是:
self.vcSettings = [[ViewControllerSettings alloc] initWithNibName:@"ViewControllerSettings" bundle:[NSBundle mainBundle]];
[self presentModalViewController:self.vcSettings animated:YES];
当它运行时,我得到一个空白屏幕,而不是我的 ViewControllerSettings.xib 里面的内容。我想我以某种方式错误地显示了视图。任何建议表示赞赏。
编辑:
我觉得应该是这样的
[self.navigationController presentModalViewController:self.vcSettings animated:YES];
但由于某种原因,self.navigationController 为零。
编辑:
Self 是在我的 AppDelegate 中实例化的 UIViewController,如下所示:
UIViewController* viewMain = [[ViewController_iPhone alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = viewMain;
[self.window makeKeyAndVisible];
【问题讨论】:
-
如何将方法切换到 [self presentViewController:self.vcSettings animated:YES 完成:^ { NSLog(@"%@", self.presentedViewController); }];控制台上打印什么? self.presentedViewController 对象是 nil 吗?
-
确保 viewcontroller 的
view出口连接到其 xib 中的根视图。 -
@Vladim,谢谢,视图连接在根视图 xib 中
-
@Jacob,如果我运行它,那条线会在 main 中给我一个 sigabrt
标签: ios modal-dialog xib presentmodalviewcontroller