应用程序在设备上崩溃但在模拟器上没有崩溃

时间:2013-06-12 18:38:35

标签: ios crash ipad ios-universal-app

我正在开发一款通用应用。它在iPhone和iPad模拟器以及iPhone 4S上运行良好,但它在iPad上崩溃。它是iPad上的分割视图,只有在打开某些视图时才会崩溃。有些视图工作正常并且没有问题,但在其他视图中,当在主视图中选择某一行以在详细视图中显示新视图时,它会崩溃。如果我在iPad模拟器上运行它,有问题的视图就可以了。有什么想法吗?

以下是我在主视图中选择行时在详细视图中显示问题视图的方法。我在此视图中有一个搜索栏,搜索栏出现但地图视图没有。同样,iPad模拟器上的一切运行正常。

else if (indexPath.row == 8)
    {
        RSFMipad *rsfm = [[RSFMipad alloc]initWithNibName:nil bundle:nil];
        NSMutableArray *details = [self.splitViewController.viewControllers mutableCopy];

        UINavigationController *detailNav = [[UINavigationController alloc]initWithRootViewController:rsfm];

        [details replaceObjectAtIndex:1 withObject:detailNav];

        KFBAppDelegate *appDelegate = (KFBAppDelegate *)[[UIApplication sharedApplication]delegate];
        appDelegate.splitViewController.viewControllers = details;
        appDelegate.window.rootViewController = self.splitViewController;
        appDelegate.splitViewController.delegate = rsfm;
        [appDelegate.splitViewController viewWillAppear:YES];
    }

这是另一个我从主视图中的另一行加载另一行的地方。这个不会立即填充详细信息视图,而是在主视图中加载新的表视图。这个也会导致iPad崩溃但不会导致模拟器崩溃。

else if (indexPath.row == 6)
    {
        MemberBenefitsipad *benefits = [[MemberBenefitsipad alloc] initWithNibName:@"MemberBenefitsipad" bundle:[NSBundle  mainBundle]];
        [self.navigationController pushViewController:benefits animated:YES];
    }

日志中显示的错误错误是:

2013-06-12 14:36:54.267 KFBNewsroom[12125:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/ED63F1DA-31C8-4FC1-81D7-A3DCE3186C98/KFBNewsroom.app> (loaded)' with name 'MemberBenefitsipad''
编辑:我解决了这个问题。我只需要将xib文件放在bundle资源中。

1 个答案:

答案 0 :(得分:1)

此问题可能是由xib文件的名称引起的。您没有名为MemberBenefitsipad的xib。

如果iPhone和iPad的视图控制器有不同的xib文件,请为iPhone命名为“MyXibFile~ipad.xib”(适用于iPad)和“MyXibFile~iphone.xib”等文件,当您尝试加载xib仅使用“MyXibFile”字符串而不是整个名称,这样操作系统将根据设备加载所需的xib。

另外要注意资源和xib命名,因为模拟器不区分大小写(MyXibFile = myxibfile)但设备区分大小写(MyXibFile!= myxibfile)