Ios7 iPad Landscape Only App, Using Uiimagepickercontroller

iOS7 iPad Landscape only app, using UIImagePickerController

If your iPad app is landscape only in all conditions, just do these 3 steps :

1) In your app delegate

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}

2) Create a category header

#import "UIViewController+OrientationFix.h"

@implementation UIViewController (OrientationFix)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

- (BOOL)shouldAutorotate {
return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}

@end

3) Create a category implementation

#import "UIImagePickerController+OrientationFix.h"

@implementation UIImagePickerController (OrientationFix)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

- (BOOL)shouldAutorotate {
return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}

@end

Note: You don't need to import these categories anywhere, just enough they are compiled with the project

Note: no need to implement these methods in any VC

Note: no need to change your plist supported orientations

This is tested and working under any conditions

iOS 7 Landscape only app can't access photo library

yes, I have similar issue in an app

you can add Portrait mode support to app but limit all other views to only support landscape,
mode, then image picker will work

UIImagePickerViewController only works on portrait mode

to restrict other views only support landscape mode, override - (NSUInteger)supportedInterfaceOrientations in your view controller

- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}

Landscape only iPad app displays UIImagePicker in portrait orientation

OK, I solved this, the issue was that I was presenting the UIImagePickerController in a UIPopover which Apple says not to do when the source type is the camera, instead present it full screen just like you would any other view controller.

Hope this helps someone else too...

Orientation issue in Landscape mode while opening camera in iOS 7 in iPhone

I found my solution from the link iOS7 iPad Landscape only app, using UIImagePickerController.

It worked for me like a charm.

Hope it help someone else also.

Thanks for your help people.

UIImagePickerController in Landscape

I haven't checked whether this is illegal, but it worked for me.
If you want the UIImagePickerController to start(and stay) in Landscape orientation code:

//Initialize picker

UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;


//set Device to Landscape. This will give you a warning. I ignored it.
//warning: 'UIDevice' may not respond to '-setOrientation:'


[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

//Set Notifications so that when user rotates phone, the orientation is reset to landscape.
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

//Refer to the method didRotate:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];

//Set the picker source as the camera
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

//Bring in the picker view
[self presentModalViewController:picker animated:YES];

The method didRotate:

- (void) didRotate:(NSNotification *)notification

{
//Maintain the camera in Landscape orientation
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

}


Related Topics



Leave a reply



Submit