This question already has an answer here:
-
Crash on presenting UIImagePickerController under iOS 6.0
5 answers
My current program only support landscape orientation.
In iOS 6, it crash on UIPopoverController
.
'UIApplicationInvalidInterfaceOrientation', reason: 'Supported
orientations has no common orientation with the application, and
shouldAutorotate is returning YES'
I enable all orientation for project , it's working well. However, I need to change a lot for all of the views to only support landscape.
Is there other easy way to fix , UIOrientation
in UIPopoverController
?
Try adding the following to your UIApplicationDelegate
:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}
You can still set your supported interface orientations in your Info.plist
file and by returning a mask in each view controller's supportedInterfaceOrientations:
method.
New a subclass of UIImagePickerController and add this codes:
@property (nonatomic)NSUInteger supportedInterfaceOrientations;
-(NSUInteger)supportedInterfaceOrientations{
return _supportedInterfaceOrientations;
}
-(BOOL)shouldAutorotate{
return YES;
}
Use it like this:
if (imagePickerController==nil) {
imagePickerController = [[WUIImagePickerController alloc]init];//the subclass
imagePickerController.delegate = self;
imagePickerController.supportedInterfaceOrientations = UIInterfaceOrientationMaskLandscapeRight;//any orientation you want to set
if (popoverController==nil) {
popoverController = [[UIPopoverController alloc]initWithContentViewController:imagePickerController];
}
}
Who knows a better way please tell me.
@interface NonRotatingUIImagePickerController : UIImagePickerController
@end
@implementation NonRotatingUIImagePickerController
- (BOOL)shouldAutorotate
{
return NO;
}
@end
UIImagePickerController *picker = [[NonRotatingUIImagePickerController alloc] init];
Use Above Code, this worked for me.
Thy this link. You have to set your application to support all orientations at the start. Do the change in app delegate.
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return UIInterfaceOrientationMaskAll;
else /* iphone */
return UIInterfaceOrientationMaskAllButUpsideDown;
}
Use these delegates for orientation,
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}