我正在开发一个通用应用程序。它在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文件放在捆绑资源中。