简体   繁体   English

pushViewController在iOS 5上不起作用(在iOS 6上确定)

[英]pushViewController Not Working on iOS 5 (OK on iOS 6)

I have a UINavigationController that displays several buttons on screen. 我有一个UINavigationController,它在屏幕上显示几个按钮。 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. 我有一个这样的视图控制器,但是仅在iOS 5上导致此行崩溃。它在iOS 6上运行良好。我感到困惑。 There are no real details to the crash. 崩溃没有真正的细节。 It is a SIGABRT that highlights the main.m line: 这是SIGABRT,突出显示了main.m行:

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

I have no clue... 我没有任何线索...

  1. You Need to unCheck the Auto Layout. 您需要取消选中自动版式。

在此处输入图片说明

  1. And make sure you are changing here also.. select ios 5.1 并确保您也在此处进行更改。选择ios 5.1

在此处输入图片说明

Try this line: 试试这一行:

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

in place of: 代替:

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

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. (如果您使用的是xib文件),例如提到的Venkat Manohar Perepa ,请检查“使用自动布局”是否已关闭,因为它是iOS 6的特定功能。
  • (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 (eg: NSLayoutConstraint) (如果您使用的是xib文件)请查看展示您的ViewController时使用的xib文件的内容,并检查是否没有特定于iOS6的类(例如:NSLayoutConstraint)
  • Last (and that was the issue I was facing) you should check if the crash appear on a device that has iOS5 installed. 最后(那是我面临的问题),您应该检查当机问题是否出现在已安装iOS5的设备上。 If it doesn't but still crash on the simulator remove the application you have installed by choosing iPhone Simulator > Reset Content and Settings. 如果没有,但是仍然在模拟器上崩溃,请通过选择“ iPhone模拟器”>“重置内容和设置”来删除已安装的应用程序。

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

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