0

I have portrait only app which do video capturing and some other tasks! everything is working fine, I want to keep app in portrait, but Camera view in landscape only. I have rotated single view test in portrait app by using UIInterfaceOrientationMask but Rotating Camera view caused the Following Crash:

Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

for further info I m using following line to insert show camera. I insert camera view only when app is in landscape. I use following line of code to show camera!

[self.view insertSubview:imagePicker.view atIndex:0];

any solution/suggestion please?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
AsifHabib
  • 944
  • 9
  • 25
  • Take a look at this SO question http://stackoverflow.com/questions/12540597/supported-orientations-has-no-common-orientation-with-the-application-and-shoul – Boran Apr 11 '14 at 06:58
  • @BoranA First two high votes solutions did not worked on iOS 7, comments underneath 3rd solutions are before iOS 7. (headbang) :( – AsifHabib Apr 11 '14 at 07:23
  • :) What is your root view controller? – Boran Apr 11 '14 at 07:27
  • I m using JASidepanel! center view, I push a view, and then insert camera screen view as mention above code, if I make presentModalViewController it works fine, but camera view do not go in landscape. :( – AsifHabib Apr 11 '14 at 07:33
  • 1
    Important: The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code. – Boran Apr 11 '14 at 07:41
  • This is from picker controller's class reference. – Boran Apr 11 '14 at 07:44
  • 100% true and I have read this already! if you open a native camera and rotate the device, controls are rotated. If I add UIImagePicker as a subview, it gets rotated but if I add it as presentModalViewController it do not get rotated :( – AsifHabib Apr 11 '14 at 07:45

1 Answers1

0

First change your orientation settings to support landscape and portrait. Create a UINavigationController category and add this lines. (I assume that your center view controller is a navigation controller)

- (BOOL)shouldAutorotate {

    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskPortrait;
}

and present your image picker.

Edit: In iOS7 this method is not working. I guess the only proper way is creating a layer for camera controls and subclass uiimagepickerview to support landscape only.

Boran
  • 949
  • 10
  • 17