【问题标题】:objective c - after picking image from gallery or camera - needs to enable rotate, flip editing目标 c - 从图库或相机中选择图像后 - 需要启用旋转、翻转编辑
【发布时间】: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


【解决方案1】:

您可以使用基于 swift 的框架 IGRPhotoTweaks 来旋转、翻转和裁剪图像。 您可以检查 https://github.com/IGRSoft/IGRPhotoTweaks 的 git 和 https://cocoapods.org/pods/IGRPhotoTweaks 用于 cocoapods。 在框架中cropAction()changedAngel(value: radians) 是您需要尝试实现您的要求的两种方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-09
    • 1970-01-01
    相关资源
    最近更新 更多