在我的应用程序委托(delegate)中,我有:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[CGMContainerViewController alloc] init];
self.window.rootViewController = self.viewController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
我有一个未修改的 CGMContainerViewController.h/m 和一个修改后的 CGMContainerViewController.xib (添加了一个按钮)。该 View 链接到文件所有者。
为什么 XIB 的 View 没有显示?
编辑:是因为我正在尝试将带有状态栏的 View 加载到窗口中吗?
最佳答案
从代码的外观来看,您没有加载任何 XIB 文件。您需要调用 initWithNibName:
self.viewController = [[CGMContainerViewController alloc] initWithNibName:
@"CGMContainerViewController" bundle: nil];
关于objective-c - 为什么 UIViewController 没有加载我的 XIB 文件中的 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10407714/