Warning: Attempt to present <UIImagePickerController: 0x292b400> on xxx which is already presenti

来源:互联网 发布:江恩时间周期理论,知乎 编辑:程序博客网 时间:2024/06/05 15:22

iOS8中使用 UIActionSheet  跳转到相机出错. UIActionSheet : UIView

// UIActionSheet is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet instead

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

在iOS8以前的方法里,直接在Click的委托事件里处理就好了,

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

但是在iOS8,系统会抛出警告,并且取消弹出ImagePicker行为。

Warning: Attempt to present <UIImagePickerController: 0x15c8a0000>  on <WCProfileController: 0x15c53cc50> which is already presenting (null)

 

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

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

0 0