您的位置:首页 > 产品设计 > UI/UE

On iPad, UIImagePickerController must be presented via UIPopoverController

2015-04-28 12:03 239 查看
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方法即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: