简体   繁体   中英

App Crashes on Device but Not on Simulator

I am working on a universal app. It runs just fine on both iPhone and iPad simulators and on an iPhone 4S but it crashes on an iPad. It is a split view on the iPad and it is only when opening certain views that it crashes. Some of the views work just fine and there are no issues but on others it crashes when selecting a certain row in the master view to show a new view in the detail view. The views in question open just fine if I run it on the iPad simulator. Any ideas?

Here is how I am showing one of the problem views in the detail view when selecting its row in the master view. I have a search bar in this view and the search bar comes up but the map view doesn't. Again, everything runs fine on the iPad simulator.

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];
    }

And here is another where I load another one from a different row in the master view. This one doesn't immediately populate the detail view but instead load a new table view in the master view. This one also causes a crash on an iPad but not in the simulator.

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

The error error that shows in the log is:

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''

EDIT: I solved the problem. I just had to put the xib files in bundle resources.

This issue is probably caused by the names of your xib files. You don't have a xib named MemberBenefitsipad .

If you have different xib files for a view controller for iPhone and iPad name the files like this "MyXibFile~ipad.xib" (for iPad) and "MyXibFile~iphone.xib" for iPhone and when you try to load the xib use only the "MyXibFile" string not the entire name, in this way the OS will load the required xib depending on the device.

Also be careful whit the resources and xib naming because the simulators are not case sensitive (MyXibFile = myxibfile) but the device are case sensitive (MyXibFile != myxibfile)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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