-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
以前都是用这个方法获取点击事件,然后弹出 UIImagePickerController 但是IOS8后在iPad上此方法不能正确弹出了;
原因:UIActionSheet改父于UIAlertController,所以弹出 UIImagePickerController时因为已经有actionsheet存在了,不能present新的。
解决方案:不调用以前旧方法,调用 方法
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
if(buttonIndex==actionSheet.cancelButtonIndex){return;}
//照相 或 从相册选取
UIImagePickerControllerSourceType type = UIImagePickerControllerSourceTypePhotoLibrary;
if([UIImagePickerController isSourceTypeAvailable:type])
{
if(buttonIndex==0 && [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
type = UIImagePickerControllerSourceTypeCamera;
}
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.allowsEditing = NO;
picker.delegate = self;
picker.sourceType = type;
[self presentViewController:picker animated:YES completion:nil];
}