2

I have previously solved a camera overlay issue: like this

CGSize screenBounds = [UIScreen mainScreen].bounds.size;

CGFloat cameraAspectRatio = 4.0f/3.0f;

CGFloat camViewHeight = screenBounds.width * cameraAspectRatio;
CGFloat scale = screenBounds.height / camViewHeight;

self.picker.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenBounds.height - camViewHeight) / 2.0);
self.picker.cameraViewTransform = CGAffineTransformScale(self.picker.cameraViewTransform, scale, scale);

but now in iOS 8 there's a black bar a the bottom of the live photo preview again. so scaling like this no longer works:

self.picker.cameraViewTransform = CGAffineTransformScale(self.picker.cameraViewTransform, scale, scale);

I'm not able to scale the cameraViewTransform. Any ideas on how to get this to work with iOS 8? Has this been deprecated?

Community
  • 1
  • 1
djburdick
  • 11,762
  • 9
  • 46
  • 64
  • are you aware about changes in screen bound ?? http://stackoverflow.com/questions/24150359/is-uiscreen-mainscreen-bounds-size-becoming-orientation-dependent-in-ios8 – Jageen Sep 09 '14 at 12:27
  • @Jageen: I am facing exactly the same issue as djburdick. I was using the same code to scale the UIImagePickerController in iPhone 5 size device. But, the same fails in iOS 8. Keeping the changes regarding screen bound in iOS 8 in mind, what should be the change in above code snippet? I am not able to figure out. Please help. – Rashmi Ranjan mallick Sep 27 '14 at 20:04
  • @djburdick: did you get any solution for this issue in iOS 8? Please let me know. It will help me a lot!! – Rashmi Ranjan mallick Sep 27 '14 at 20:06
  • Any solutions on this please share? – Waleed Mahmood Oct 14 '14 at 16:20
  • I just posted about this problem, which appears to be a bug in iOS 8. My solution was to make attach a `UIPinchGestureRecognizer` to the custom overlay and manually handle the zoom. See: http://stackoverflow.com/q/30288950/2397253 – oarfish May 20 '15 at 09:12

1 Answers1

0

In iOS 8 you no longer need to scale if you want to fill the screen. So the unique thing you have to do is to comment the assignment:

//self.picker.cameraViewTransform

That is to say, self.picker.cameraViewTransform = CGAffineTransformMakeScale(1.0, 1.0) conforms to self.picker.view.frame automatically.

In conclusion, the work is already done for you by UIImagePickerController.

apascualb
  • 1,049
  • 8
  • 6
  • Is it true really? I have not checked it. But is it working without the transform? – Rashmi Ranjan mallick Mar 18 '15 at 15:48
  • 1
    Without the transform, in 8.2, I get a failure to correctly rotate the preview correctly, which is far worse than the black bar problem. – Tony Adams Mar 18 '15 at 18:31
  • Where did Tony Adams see anything regarding rotation within the question? You should assess the response for the question. This method really works conforming to the original question. – apascualb Apr 21 '15 at 13:14