iPad方向更改返回SIGABRT信号

时间:2011-11-18 18:06:09

标签: ios ipad uitableview orientation

我正在创建一个应用程序,当我加载应用程序并更改方向时,它能够处理方向。但是,如果我点击RootViewController中的任何TableViewCell,在DetailViewController中为splitViewBased应用程序显示一个表,然后更改方向,那么我的应用程序会与SIGABRT崩溃,并提供以下消息:

   *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UITableViewReorderingSupport count]: unrecognized selector sent to instance 0x4e4eb30'

我写的处理方向的方法是:

// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    //hot fix sometimes in multilevel bar button is shown in landscape mode.

    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        [[self navigationItem] setLeftBarButtonItem:nil];
    }
    else {
        [[self navigationItem] setLeftBarButtonItem:self.appDelegate.rootPopoverButtonItem];
    }   
    return YES;
}

2 个答案:

答案 0 :(得分:2)

您很可能正在使用数组将内容加载到表中,并且在重新加载或用内容填充表时,数组计数可能为0或数组实例将丢失其范围,并且您将尝试直接从cellForRowAtIndexPath委托访问它。如果是这样,那么尝试保留数组或分配它。

答案 1 :(得分:0)

在if和else之后添加NSLog以确保它正在读取每个NSLog并查看崩溃的位置。如果有didRotateTo或didRotateFrom,也可以在那里添加NSLog以查看发生了什么。

也可以尝试在shouldAutorotate中返回YES:并在if / else中使用nix以确保它正确旋转并且没有其他任何阻碍。

最后,检查目标>支持的设备方向以确保支持所有方向