应用程序在 iPod touch 上崩溃,但在 iPhone 模拟器上则不然
我按照苹果教程 “您的第一个 iOS 应用程序” 一步一步,它在 iPhone 模拟器上完美运行。
但当我尝试将其部署到 iPod touch 上时,应用程序崩溃了。
这是有问题的方法:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
MyViewController *acontroller = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];
[self setMyViewController:acontroller];
[[self window] setRootViewController:[self myViewController]]; // crash here
[self.window makeKeyAndVisible];
[acontroller release];
return YES;
}
这是错误消息:
011-04-13 18:07:53.730 ios_HelloWorld[865:207] *** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x119520
2011-04-13 18:07:53.754 ios_HelloWorld[865:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x119520'
2011-04-13 18:07:53.770 ios_HelloWorld[865:207] Stack: (
843631901,
849079828,
843635709,
843131673,
843094080,
11801,
857435720,
857434728,
857767424,
857765436,
857763988,
875472868,
843380011,
843377695,
857431048,
857424432,
11553,
11476
)
terminate called after throwing an instance of 'NSException'
考虑到我已经一步一步地遵循了教程(并由我自己重新完成),并且它总是在这个地方崩溃。
有什么想法吗?
谢谢基特
I followed the apple tutorial "Your First iOS Application" step by step and it works perfectly on the iPhone emulator.
But when I attempt to deploy it on an ipod touch, the application crashes.
here is the problematic method :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
MyViewController *acontroller = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];
[self setMyViewController:acontroller];
[[self window] setRootViewController:[self myViewController]]; // crash here
[self.window makeKeyAndVisible];
[acontroller release];
return YES;
}
And here is the error message :
011-04-13 18:07:53.730 ios_HelloWorld[865:207] *** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x119520
2011-04-13 18:07:53.754 ios_HelloWorld[865:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x119520'
2011-04-13 18:07:53.770 ios_HelloWorld[865:207] Stack: (
843631901,
849079828,
843635709,
843131673,
843094080,
11801,
857435720,
857434728,
857767424,
857765436,
857763988,
875472868,
843380011,
843377695,
857431048,
857424432,
11553,
11476
)
terminate called after throwing an instance of 'NSException'
Consider that I have followed the tutorial step by step (and re-did it by my own) and it always crashes at this spot.
Any idea?
thanks
KiTe
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
self.window.rootViewController 与窗口 addSubview
self.window.rootViewController vs window addSubview
查看文档,所需的属性在该 iOS 版本上不可用。您将必须更新或构建一些有条件的解决方法。
Have a look at the documentation, the desired property is not available on that iOS Version. You will have to update or build in some conditional workaround.
setRootViewController方法仅在iOS 4.0及以上版本中可用。
The setRootViewController method is only available in iOS 4.0 and above.