UIImagePickerController - SourceType Camera - Allo

2019-08-31 04:12发布

问题:

I want to prevent user from taking photo at the landscape orientation and allow only portrait. Is there a way you know to accomplish this?

Thanks in advance!

回答1:

There are different things to consider here:

1) you want the camera button not to change for Landscape orientation (to indicate Portrait orientation only).You can achieve this by having custom controls and having your own Camera Control Bar.

camController.showsCameraControls = NO; // this will disable the default controls camController.cameraOverlayView = controlsView; // this view shows the required camera button in portrait only way.

2) Modifying the image data after capture

This is a tedious thing (already mentioned in many blogposts/stackoverflow)

UIImagePickerController camera preview is portrait in landscape app

Now rotate your image by 90 degrees (or 270 deg based on orientation) to make it look portrait.