iPad 方向改变返回 SIGABRT 信号
我正在制作一个应用程序,其中当我加载应用程序并更改方向时,它能够处理方向。但是,如果我点击 RootViewController 中的任何 TableViewCell 以在 splitViewBased 应用程序的 DetailViewController 中显示表格,然后更改方向,那么我的应用程序会因 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;
}
I am making an app wherein when I load the app and change the orientation, it is able to handle the orientation. But if I tap on any TableViewCell in RootViewController to display a table in DetailViewController for a splitViewBased app and then change the orientation then my app crashes with SIGABRT and gives the following message :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UITableViewReorderingSupport count]: unrecognized selector sent to instance 0x4e4eb30'
The method that I am writing to handle orientation is :
// 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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您很可能会使用数组将内容加载到表中,并且在重新加载或用内容填充表时,数组计数可能为 0 或者数组实例将失去其范围,您将尝试直接从 cellForRowAtIndexPath 委托访问它。如果是这样,则尝试保留该数组,或分配它。
You would most probably be using an array to load the contents to the table, and at the point of reloading or filling the table with contents, the array count might be 0 or the array instance would have lost its scope, and you would be trying to access it directly from cellForRowAtIndexPath delegate. If it is so, then try retaining the array, or allocating it.
在 if 和 else 之后添加 NSLog 以确保它正在读取每一个并查看是否发生崩溃。如果有 didRotateTo 或 didRotateFrom,也在那里添加 NSLog 以查看发生了什么。
还可以尝试在 shouldAutorotate 中返回 YES: 并取消 if/else 以确保它正确旋转并且没有其他任何阻碍。
最后,检查您的目标>支持的设备方向以确保支持所有方向
Add NSLog after the if and else to make sure it's reading each one and see if where the crash is. If there's the didRotateTo or didRotateFrom, add NSLog there too to see what's going on.
Also try just return YES: in the shouldAutorotate and nix the if/else to make sure it does rotate properly and there's nothing else getting in the way.
Lastly, check your Target > Supported Device Orientation to make sure all orientations are supported