iOS8中UIActionSheet弹出UIImagePickerController异常处理

iOS8之后,UIActionSheet改父于UIAlertController。带来了一丢丢兼容性的问题。

比如在弹出的actionsheet中选择从相册选择图片或者拍照,之后弹出UIImagePickerController进行选择。

在iOS8以前的方法里,直接在

-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;

Click的委托事件里处理就好了,但是在iOS8,系统会抛出警告

Warning: Attempt to present <UIImagePickerController: 0x292b400>on <**Controller: 0x723c150> which is already presenting <UIAlertController: 0xd37b8b0>

并且取消弹出ImagePicker行为。

原因在警告里说得比较明白了,,因为已经有actionsheet存在了,不能present新的。此时我们选择新的委托方法

– (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;

didDismissWithButtonIndex方法即可。

如果心在远方,只需勇敢前行,梦想自会引路,

iOS8中UIActionSheet弹出UIImagePickerController异常处理

相关文章:

你感兴趣的文章:

标签云: