应用程序在 iPod touch 上崩溃,但在 iPhone 模拟器上则不然

发布于 2024-11-01 06:08:58 字数 1603 浏览 1 评论 0原文

我按照苹果教程 “您的第一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无所谓啦 2024-11-08 06:08:58

查看文档,所需的属性在该 iOS 版本上不可用。您将必须更新或构建一些有条件的解决方法。

rootViewController 根视图
窗口控制器。

@property(非原子,保留)
UIViewController *rootViewController
讨论根视图控制器
提供的内容视图
窗户。将视图控制器分配给
该属性(以编程方式
或使用 Interface Builder)安装
视图控制器的视图为
窗口的内容视图。如果
窗口有一个现有的视图层次结构,
旧视图在之前被删除
新的已安装。

该属性的默认值为
无。

适用于 iOS 4.0 和
稍后。

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.

rootViewController The root view
controller for the window.

@property(nonatomic,retain)
UIViewController *rootViewController
Discussion The root view controller
provides the content view of the
window. Assigning a view controller to
this property (either programmatically
or using Interface Builder) installs
the view controller’s view as the
content view of the window. If the
window has an existing view hierarchy,
the old views are removed before the
new ones are installed.

The default value of this property is
nil.

Availability Available in iOS 4.0 and
later.

浅暮の光 2024-11-08 06:08:58

setRootViewController方法仅在iOS 4.0及以上版本中可用。

The setRootViewController method is only available in iOS 4.0 and above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文