pushViewController Not Working on iOS 5 (OK on iOS 6)

大兔子大兔子 提交于 2019-12-11 09:56:38

问题


I have a UINavigationController that displays several buttons on screen. They all simply use the line:

myViewController *newView = [[myViewController alloc] initWithNibName:@"myViewController"
                                                                          bundle:nil];
[[self navigationController] pushViewController:newView animated:YES];

to transition to the next view. I have one such view controller however that results in a crash at this very line ONLY on iOS 5. It works perfectly fine on iOS 6. I am baffled. There are no real details to the crash. It is a SIGABRT that highlights the main.m line:

exitStatus = UIApplicationMain( argc, argv, nil, NSStringFromClass([ApplicationDelegate class]));

I have no clue...


回答1:


  1. You Need to unCheck the Auto Layout.

  1. And make sure you are changing here also.. select ios 5.1




回答2:


Try this line:

myViewController *newView = [[myViewController alloc] initWithNibName:@"myViewController"
                                                                              bundle:[NSBundle mainBundle]];

in place of:

myViewController *newView = [[myViewController alloc] initWithNibName:@"myViewController"
                                                                          bundle:nil];



回答3:


I have experimented a similar issue an here are the steps that I feel need to be considered:

  • (if you are using xib file) like Venkat Manohar Perepa mentioned, check that Use Auto Layout is turned off as it is an iOS 6 specific feature.
  • (if you are using xib file) look at the content of the xib file that is used when presenting your viewcontroller and check that there is no class that are iOS6 specific (e.g: NSLayoutConstraint)
  • Last (and that was the issue I was facing) you should check if the crash appear on a device that has iOS5 installed. If it doesn't but still crash on the simulator remove the application you have installed by choosing iPhone Simulator > Reset Content and Settings.


来源:https://stackoverflow.com/questions/13714997/pushviewcontroller-not-working-on-ios-5-ok-on-ios-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!