在我的应用程序中,我制作了包含5个标签的自定义标签栏,每个标签显示不同的UIViewController
。
应用程序仅适用于iPhone,因此我为每个UIViewController
制作了2个NIB(如果类名是DayView,则NIB是DayView_iPhone和DayView_iPhone5)。在设备和模拟器中,一切工作正常,最长可达10分钟。
该应用程序崩溃后,在控制台中显示:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/kalyanasadinagarajugari/Library/Application Support/iPhone Simulator/6.1/Applications/0DEBB118-BA67-440F-BA70-79ED41AC9134/CalendarBlender.app> (loaded)' with name 'DayView_iPhone''
我也检查了NIB名称,每个NIB文件名都是正确的。
我的代码是
NSString *nibName = [AppDelegate fetchNibWithViewControllerName:@"DayView"];
dayView = [[DayView alloc] initWithNibName:nibName bundle:nil];
if (IS_IPHONE_5)
dayView.view.frame = CGRectMake(0, 44, 320, 463);
else
dayView.view.frame = CGRectMake(0, 44, 320, 375); dayView.view.tag=2; [self.view
addSubview:dayView.view];
答案 0 :(得分:0)
尝试检查Nibname(区分大小写)并清理项目,重新运行它。你是否更改了所有笔尖的类名?
答案 1 :(得分:0)
使用此:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
tabBarController = [[UITabBarController alloc] init];
MyViewController* vc1 = [[MyViewController alloc] initWithNibName:@"nibName" bundle:nil];
MyOtherViewController* vc2 = [[MyOtherViewController alloc] initWithNibName:@"nibName" bundle:nil];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil];
tabBarController.viewControllers = controllers;
window.rootViewController = tabBarController;
}
您也可以通过在tabBarController的viewControllers数组中添加控制器来动态添加控制器。