0

在我的应用程序中,我制作了具有 5 个选项卡的自定义选项卡栏,每个选项卡显示不同的UIViewController.

应用程序仅适用于 iPhone,所以我为每个制作了 2 个UIViewControllerNIB(如果类名是 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];
4

2 回答 2

0

尝试检查 Nibname(区分大小写)并清理项目,重新运行它。您是否更改了所有笔尖的类名?

于 2013-08-16T10:28:27.283 回答
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 数组中添加控制器来动态添加控制器。

于 2013-08-16T10:54:46.613 回答