UIImagePickerController not presenting in iOS 8

后端 未结 12 1575
借酒劲吻你
借酒劲吻你 2020-12-12 16:39

Is anyone else having an issue with UIImagePickerController in iOS 8? The method below works perfectly well in iOS 7 on an iPad, but I get the following error

12条回答
  •  萌比男神i
    2020-12-12 16:49

    I think this is because in iOS 8, alert views and action sheets are actually presented view controllers (UIAlertController). So, if you're presenting a new view controller in response to an action from the UIAlertView, it's being presented while the UIAlertController is being dismissed. I worked around this by delaying the presentation of the UIImagePickerController until the next iteration of the runloop, by doing this:

    [[NSOperationQueue mainQueue] addOperationWithBlock:^{
        [self openPhotoPicker:sourceType];
    }];
    

    However, the proper way to fix this is to use the new UIAlertController API on iOS 8 (i.e. use if ([UIAlertController class]) ... to test for it). This is just a workaround if you can't use the new API yet.

提交回复
热议问题