0

我的应用程序在模拟器中运行得很好,但现在我有一个开发者许可证,当我尝试在我的 iPod Touch 上运行它时,xcode 说GBD: Program received signal: "SIGABRT".

我该怎么做才能找出问题所在?它在构建时不会发出警告。

编辑:对不起,这是我第一次在设备上运行应用程序,所以请多多包涵。我刚刚注意到管理器窗口和调试器正在给我记录设备上发生的事情。所以这就是问题所在:

[UIApplication setStatusBarHidden:withAnimation:]: unrecognized selector sent to instance 0x1160e0

它所指的代码在(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

这是它有问题的代码:

`if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {

    self.view = clockView;
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
    return YES;


}
if (interfaceOrientation == UIInterfaceOrientationPortrait) {

    self.view = homeView;

    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];

    return YES;
}
if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {

self.view = homeView; [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];

    return YES;
}
else {
    return YES;
}

`

4

3 回答 3

3

[UIApplication setStatusBarHidden:withAnimation:]:无法识别的选择器发送到实例 0x1160e0

您的设备上似乎不存在该方法。它是在 3.2 上添加的。您的 iPod 运行的是哪个 iOS 版本?另外,第二个参数类型错误

如果它更低,并且你想支持它,你应该考虑

    if ([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarHidden:withAnimation:)]) {
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
    } else {
        [[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];
    }
于 2011-01-27T12:40:01.390 回答
1

在代码的最开始插入断点,并在调试模式下运行它。使用调试器逐行执行代码,并查看在 SIGABRT 发生之前您的代码执行了多远。

但是您是否将 iPod touch 设置为配置设备?

哦,刚刚发现了别的东西。我不确定您是否将正确的数据发送到 withAnimation 参数。检查文档:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO]; 

应该是这样的:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; 
于 2011-01-27T11:51:30.773 回答
0

当您在调试模式下运行应用程序时,您可以监控控制台(运行->控制台)。对于大多数崩溃,您会收到某种错误消息,为您指明正确的方向。此外,在调试视图中,您将能够看到应用程序崩溃时的堆栈(Xcode 默认布局中调试视图的左上角)。Xcode 将用深色文本突出显示堆栈中属于您的代码的方法。这些是第一批嫌疑人。

于 2011-01-27T11:50:45.217 回答