UIImagePickerController using iOS 8 cameraViewTransform isn't scaling

穿精又带淫゛_ 提交于 2019-12-30 11:07:37

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/25734962/uiimagepickercontroller-using-ios-8-cameraviewtransform-isnt-scaling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!