在iOS 10 Objective-C和
Xcode 8中从图像选择器中选择一个图像.我收到一个错误 –
Creating an image format with an unknown type is an error
.
对于以前的版本是可以的.
这是我的代码:
UIImagePickerController* imgPicker=[[UIImagePickerController alloc] init]; imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; imgPicker.delegate = self; [self presentViewController:imgPicker animated:YES completion:nil];
并且代理回收图像的方法是..
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissViewControllerAnimated:YES completion:NULL]; UIImage *myImage = [info objectForKey:UIImagePickerControllerOriginalImage]; }
我也试过其他委托函数..
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{ }
但错误不行.
解决方法
这是一个bug.这只是一个假警告.应用程序的工作没有坏事,所以忽略警告.