我想从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];
view
插座已连接到其 xib 中的根视图。 - Vadim Yelagin