在我的应用程序中,我制作了具有5个选项卡的自定义选项卡栏,每个选项卡显示不同的UIViewController。
应用程序仅适用于iPhone,因此我为每个UIViewController创建了两个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];发布于 2013-08-16 18:28:27
尝试检查Nibname (区分大小写)并清理项目,重新运行它。您是否更改了所有nibs的类名?
发布于 2013-08-16 18:54:47
使用以下命令:
- (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数组中添加控制器来动态添加控制器。
https://stackoverflow.com/questions/18271131
复制相似问题