Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't pan image taken from camera with UIImagePicker

I'm using a UIImagePicker to get the user to take a photo. When the photo is taken, I want them to pan and zoom the image around to fit inside the cropped box so that the image is stored as a square.

However, when cropping the image, it seems as though you cannot move it to the top and bottom of a (portrait) image (left and right if landscape).

I have tried searching but there doesn't seem to be much information, but it seems like a massive issue.

Can someone help?

This is the very small amount of code I'm using:

let imagePicker = UIImagePickerController()

imagePicker.allowsEditing = true
imagePicker.sourceType = UIImagePickerControllerSourceType.camera

present(imagePicker, animated: true, completion: nil)

There's obviously more code but this is the main part.

EDIT with photo:

enter image description here

So I want to be able to move the photo around/zoom in to select any square portion to save. However, I cannot move it from this position/ keeps snapping back.

I can zoom in, but it still restricts me from the top and bottom edges.

Again, it works with the photoLibrary.

like image 433
user2397282 Avatar asked Jan 17 '17 20:01

user2397282


1 Answers

This is a bug that was introduced in iOS 6 and hasn't been fixed yet.

A radar was raised in 2012 for this but closed by Apple. I managed to get it opened again and have been pestering Apple devs in my contacts for the past 6 months.

http://openradar.appspot.com/12318774

Until this is fixed by Apple the only option is to use a third party control or do it yourself.

Here is the radar I opened...

http://openradar.appspot.com/28260087

like image 64
Fogmeister Avatar answered Oct 18 '22 15:10

Fogmeister