图像选择器问题允许编辑

时间:2015-11-05 04:10:27

标签: ios objective-c ipad uiimagepickercontroller

当用户打开相机胶卷时,我有这种方法。我允许编辑设置为YES,但是当在编辑屏幕上时,方形裁剪框仅出现在iphone而不是iPad上。我错过了什么?

- (void)useCameraRoll 
{
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
    {
        UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
        imagePicker.delegate = self;
        imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        imagePicker.mediaTypes = @[(NSString *) kUTTypeImage];
        imagePicker.allowsEditing = YES;
        if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
        {
            [self presentViewController:imagePicker animated:YES completion:nil];
        }
        else
        {
            dispatch_async(dispatch_get_main_queue(), ^{

                [self setModalPresentationStyle:UIModalPresentationFormSheet];
                [self.navigationController presentViewController:imagePicker animated:YES completion:nil];
            });
        }

    }
}

委托方法

- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSString *mediaType = info[UIImagePickerControllerMediaType];

   [self dismissViewControllerAnimated:YES completion:nil];

    if ([mediaType isEqualToString:(NSString *)kUTTypeImage])
    {
        theCustomImage = info[UIImagePickerControllerEditedImage];
        [self roundedCorners];
        [self placeImage:theCustomImage];
        customImage = true;
        UIImageWriteToSavedPhotosAlbum(theCustomImage, self, @selector(image:finishedSavingWithError:contextInfo:), nil);
    }
}

0 个答案:

没有答案