Hy, I know that this subject has been asked before, but I went over all solutions and none solved the case I'm having.
My app is all in portrait format, only one view controller in landscape format.
I added to all view controllers the following code to force Portrait Orientation regardless the device orientation:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotate{
return NO;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
-(void)ViewDidLoad()
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
}
If the device is set in portrait mode the viewController opens correctly, but if the device is set landscape mode before opening the app, then the app launches the splash screen in landscape and opens the view controller in landscape with part of the view clipped, then it rotates it to portrait mode, and keeps part of the screen clipped, as shown in the picture.
in the app delegate:
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;;
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
And in the appDelegate also, just before adding the view controller to the navigation controller I added the following:
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
Thank you for any advice on the issue.
Kindly if anything seems unclear or any info may be needed clarify the issue let me know.