繁体   English   中英

应用程序在设备上崩溃,但在模拟器上不崩溃

[英]App Crashes on Device but Not on Simulator

我正在开发通用应用程序。 它可以在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文件放在包资源中。

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM