这是一个非常奇怪的问题。
我包含下一个 View 的 .h 文件:
#import "MainGame.h"
当我按下屏幕时,我有这个代码来切换房间:
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
MainGame *newview = [[MainGame alloc] initWithNibName:@"MainGame" bundle:nil];
newview.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:newview animated:YES completion:NULL];
}
而且它在 iOS 5 模拟器中运行良好;但是当我在运行 iOS 4.2 的 iPod 上测试它时,它总是崩溃。
我所有的 IBOutlets 都已正确连接,一切如我所说,它在模拟器中工作正常,但在我的 iPod 上却不行。
我以前在我的 iPod 上使用过每个单独的 View ,所以我没有使用任何需要 iOS 5 或任何东西的功能;只是这段切换 View 的代码不起作用。
我错过了什么吗?
谢谢!
最佳答案
我认为是版本问题
[self presentViewController:newview animated:YES completion:NULL];
在 iOS 4.2 中不存在,但在 iOS 5 中存在
试试这个
[self presentModalViewController:newview animated:YES];
关于ios - 切换 View 会使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12571545/