【发布时间】:2018-05-24 03:47:17
【问题描述】:
从图库或相机中选择图像后 - 需要启用旋转、翻转编辑我如何才能启用它。这是我的代码:
-(void)photofromCamera
{
@try
{
NSLog(@"2");
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:nil];
}
@catch (NSException *exception)
{
[self showAlert:@"Camera is not available"];
}
}
-(void)photofromGallery
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
}
所以在委托方法之后:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self.imageDeletionButton setHidden:NO];
UIImage *chosenImage = [info valueForKey:UIImagePickerControllerEditedImage];
self.PostImageView.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:nil];
}
好像现在,如果我从画廊、相机中挑选任何图像 - 我需要展示裁剪、翻转、旋转。请帮助我如何实现。
提前致谢!!!
【问题讨论】:
-
仅供参考 - 摆脱
try/catch。这不是处理相机不可用的正确方法。使用UIImagePickerController isSourceTypeAvailable。 -
@rmaddy 当然可以,但我怎样才能获得翻转、旋转选项?
标签: ios objective-c camera uiimagepickercontroller