ios – imagePickerController移动和缩放不起作用

前端之家收集整理的这篇文章主要介绍了ios – imagePickerController移动和缩放不起作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的代码
-(void) takePhoto
{
    UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    //imagePickerController.editing = YES;
    imagePickerController.allowsEditing=YES;
    imagePickerController.delegate = self;

    [self presentViewController:imagePickerController animated:YES completion:NULL];
}

#pragma mark - Image picker delegate methods
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissViewControllerAnimated:NO completion:nil];

    [self.Picture setImage:[info objectForKey:UIImagePickerControllerOriginalImage]];


}

我已经执行了代表们

UINavigationControllerDelegate,UIImagePickerControllerDelegate

图像被拍摄,我可以看到移动和缩放框,但是当我移动它时,框返回到初始位置 – 喜欢它反弹.

这是为什么?

解决方法

看起来这是因为您要求UIImagePickerControllerOriginalImage,根据文档返回“由用户选择的原始的未裁剪图像”.

尝试将其更改为UIImagePickerControllerEditedImage.

https://developer.apple.com/library/ios/documentation/uikit/reference/UIImagePickerControllerDelegate_Protocol/UIImagePickerControllerDelegate/UIImagePickerControllerDelegate.html#//apple_ref/doc/constant_group/Editing_Information_Keys

编辑:实际上,在重新阅读问题几次后,如果问题出现在选择器本身,这可能不会有帮助.

猜你在找的iOS相关文章