我用ARC创建了一个tabBar应用程序。因此默认设置将自动提供2个viewControllers;
1)FirstViewController.h,FirstViewController.m; FirstViewController_iPhone.xib,FirstViewController_iPad.xib
2)SecondViewController.h,SecondViewController.m,SecondViewController_iPhone.xib,SecondViewController_iPad.xib
我想创建一个新的视图控制器'ViewController3',但在文件创建过程中,我只能选择创建iPad或iPhone(复选框'Targeted for iPad')。我需要iPhone和iPad xib,就像为我创建的FirstViewController和SecondViewControllers一样。所以我决定手动创建xib并继续创建没有xibs的文件。
之后我自然而然地手动创建了2个新闻xib; ThirdViewController_iPhone.xib和ThirdViewController_iPad.xib
我将此行添加到原始的AppDelegeate文件中:
UIViewController *viewController1, *viewController2, *viewController3;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPhone" bundle:nil];
viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController_iPhone" bundle:nil];
viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController_iPhone" bundle:nil];
} else {
viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPad" bundle:nil];
viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController_iPad" bundle:nil];
viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController_iPad" bundle:nil];
}
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil];
然后我运行该项目得到了:由于未捕获的异常'NSInternalInconsistencyException'终止应用程序,原因:' - [UIViewController _loadViewFromNibNamed:bundle:]加载了“ThirdViewController_iPhone”笔尖,但未设置视图插件。'
如何设置插座?
答案 0 :(得分:4)
对于您的ThirdViewController_iPhone.xib,请按照here指示操作。我认为你需要这样做:
- 你应该看到“outlet”下面有“view”。将其旁边的圆圈拖到左栏上的“视图”图标