0

Hello my whole app is for landscape orientation not for portrait and in one screen I used UIImagePickerController so I set Potrait, Landscape Left and Landscape Right from Target's general Deployment info. My code in AppDelegate.swift is

internal var shouldRotate = true
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
        if shouldRotate {
            return UIInterfaceOrientationMask.Landscape
        }
        else {
            return UIInterfaceOrientationMask.Portrait
        }
    }

I want to rotate be UIImagePickerController so am doing like this whenver I want to present UIImagePickerController :

let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.shouldRotate = false
picker?.allowsEditing = true
picker!.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
self.presentViewController(picker!, animated: true, completion: nil)

through this code I am able to rotate UIImagePickerController. But now issue is when I present UIImagePickerController my ViewController is LandscapeLeft and after presenting of UIImagePickerController I rotate my device and UIImagePickerController is also rotating(which is fine) and after picking of image I dismiss UIImagePickerController now problem is viewcontroller is in LandscapeRight Orientation which should be LandscapeLeft because when I present UIImagePickerController it was in LandscapeLeft orientation. sorry for my english please help me.

sohan vanani
  • 1,537
  • 1
  • 20
  • 37
  • Check out this http://stackoverflow.com/questions/19374237/using-uiimagepickercontroller-in-landscape-orientation – Singh Aug 02 '16 at 09:40
  • UIImagePickerController is opening in landscape its not an issue – sohan vanani Aug 02 '16 at 09:44
  • you need to return NO from shouldAutorotate in case of UIImagePickerController, you should try this answer http://stackoverflow.com/questions/19374237/using-uiimagepickercontroller-in-landscape-orientation/19374338#19374338 – Singh Aug 02 '16 at 09:57
  • i want to rotate UIImagePickerController. issue is when i dismiss UIImagePickerController my viewcontroller's orientation is changing. – sohan vanani Aug 02 '16 at 10:00

0 Answers0