ImagePicker设置裁剪区域大小

时间:2015-07-30 03:07:13

标签: ios objective-c uiimagepickercontroller

默认ImagePicker裁剪区域为方形(如图像)

但是我想把它设置为一个矩形,我可以得到一个矩形图像来使用

有没有简单的方法来设置它?

我知道GKImagePicker非常强大,但我不知道为什么在裁剪区域以下的图像无法向上滚动。

提前致谢

enter image description here

======编辑代码=====

 - (BOOL)startMediaBrowserFromViewController: (UIViewController*) controller
                               usingDelegate: (id<UIImagePickerControllerDelegate,UINavigationControllerDelegate>) delegate
                                        type: (int)type_{

if (([UIImagePickerController isSourceTypeAvailable:
      UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
    || (delegate == nil)
    || (controller == nil))
    return NO;

UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];

if (type_ == 0)
{
    mediaUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
else
{
    mediaUI.sourceType = UIImagePickerControllerSourceTypeCamera;
}

mediaUI.allowsEditing = YES;
mediaUI.delegate = delegate;

[controller presentModalViewController: mediaUI animated: NO];
return YES;
}

如果我可以获得矩形图像,我可以在

中调整大小
- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSLog(@"imagePickerControllerDone");

UIImage *image = (UIImage *) [info objectForKey:
                              UIImagePickerControllerEditedImage];
CGSize size = image.size;
image = [ImageManager reSizeImage:image toSize:CGSizeMake(1000, 370)];
[self dismissViewControllerAnimated:YES completion:^{
    self.carPhoto.image = image;
    photoFlag = YES;
}];
}

0 个答案:

没有答案