Xcode 8:[Generic]创建具有未知类型的图像格式是错误目标C.

时间:2016-11-25 10:18:34

标签: ios objective-c xcode8.1

使用uiimagepicker控制器时出现上述错误。这是我的代码:

- (BOOL) startCameraControllerFromViewController:(UIViewController *)controller andisImageFromCamera:(BOOL)isCameraCapture {


    if(self.picker == nil) {
        /**< instansiate UIImagePickerController object */
        self.picker = [[UIImagePickerController alloc] init];;
    }
    /**< Check isSourceTypeAvailable for possible sources (camera and     photolibrary) */
    if (([UIImagePickerController isSourceTypeAvailable:    UIImagePickerControllerSourceTypeCamera] == NO) || ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO))
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Oops!! This feature is not supported on your device" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alertView show];

        return NO;
    }

    self.picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    self.picker.delegate = self;
    self.picker.mediaTypes =[NSArray arrayWithObjects: (NSString *) kUTTypeMovie, (NSString *) kUTTypeImage, nil];
    self.picker.videoMaximumDuration = MAX_VIDEO_DURATION;
    self.picker.allowsEditing = YES;
    self.picker.videoQuality =    UIImagePickerControllerQualityTypeMedium;


    /**< if editing is required*/
    [self presentViewController:self.picker animated:YES completion:^{

    }];

    return YES;

}

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{

    NSURL *videoURL = [info valueForKey:UIImagePickerControllerMediaURL];
    NSString *pathToVideo = [videoURL path];

    if(![pathToVideo isEqualToString:@""] && pathToVideo != nil) {
        BOOL okToSaveVideo =    UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(pathToVideo);
        if (okToSaveVideo) {
            //UISaveVideoAtPathToSavedPhotosAlbum(pathToVideo, self,   @selector(video:didFinishSavingWithError:contextInfo:), NULL);
        }
    }
    if ([info[UIImagePickerControllerMediaType] isEqualToString:(NSString *)kUTTypeMovie]) {
        // video
        isVideoFromGallery = YES;
        isMediaTypeVideo = YES;
        [self videoCaptureSaveAction:videoURL andMediaInfo:info];
    }
    else{

        isMediaTypeVideo = NO;
        UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
        self.previewImage = chosenImage;
        self.capturedImageData = UIImageJPEGRepresentation(chosenImage, 90);
        [self performSegueWithIdentifier:@"previewCapture" sender:self];
    }
}

挑选视频正在运行。但是当我选择图像时,我会得到错误:[Generic]创建一个未知类型的图像格式是一个错误。我已经阅读了有关此错误的其他帖子,更改了委托方法,但仍然无法正常工作。请帮忙。

0 个答案:

没有答案