最近发现一个很棘手的 crash 问题,在8.0.x 系统上,在 action sheet 上面弹出分享界面,必现 crash, log 如下
*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[CABasicAnimation _viewControllerForSupportedInterfaceOrientationsWithDismissCheck:]: unrecognized selector sent to instance 0x15760520’
具体原因很难分析,几经波折,在 stack overflow 上发现了相关线索,在 iOS 8.0.x 系统上, AlertViewController 未完全消失前继续 present 其他的 ViewController 会导致 crash, 苹果已经在 iOS 8.1中修复了该问题,
解决办法如下: 将 action sheet delegate 中原本使用的
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
替换为
- (void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
可以加入 #ifdef __IPHONE_8_0
宏来进行区分8.0以上设备. 希望对其他人也有帮助.