My application is Landscape
based. The app crashes immediately when the app runs on my device.
I have selected these two fields
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
I am getting this error:
Terminating app due to uncaught exception
UIApplicationInvalidInterfaceOrientation, reason: Supported
orientations has no common orientation with the application, and
shouldAutorotate is returning YES
Add shouldAutorotate and supportedInterfaceOrientations methods to your controller.
-(BOOL)shouldAutorotate
{
return YES; //this will auto-rotate the orientation.
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape; // will force the app to load in landscape, you can change it as per your need.
}
shouldAutorotateToInterfaceOrientation return only those with you want to support
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
please check one more thing, the connection between the File's Owner and View
, if the view will not attach with the file's Owner It will crash.
You should use UIInterfaceOrientationMaskLandscape instead of UIInterfaceOrientationLandscapeLeft & UIInterfaceOrientationLandscapeRight. In iOS SDK 6.0+, new enum(UIInterfaceOrientationMask) is used for returning supported orientations.