iOS8 lock view controller orientation - orientation

I have 2 root view controllers ViewController1 and TabBarController1(there are reasons for making 2 root view-controllers). ViewController1 only supports Portrait mode and TabBarController1 supports all orientations. ViewController1 appears first after launch. I am locking the orientation of ViewController1 using the following method.
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
The app launch and orientation worked fine with iOS7.
When building the app through Xcode 6 in iPad(iOS8) following change is observed:
- When app is launched in landscape mode, ViewController1 with orientation locked into portrait mode appears with half black screen and when TabBarController1 appears which supports all orientations, doesn't resize with proper dimensions on changing orientations.
I have also tried overriding the above method in TabBarController1 to support all orientation but nothing works fine.
This problem is not observed when launching the app on iPad in portrait mode.
There is no problem when launching the app on iPhone as iPhone launches only in Portrait mode.
What is the issue when working with iOS8 ?

I am a newbie, so don't judge..
In ios8, apple changed 2 things :
1-
[[UIscreen mainscreen] bounds].size
This used to be a fixed value for portrait and landscape, now it is not.
When u change from landscape to portrait the width and height switch.
2-What is happening with you. You cannot force a viewcontroller to be in portrait only if you set portrait and landscape in project settings, do not know why, so you maybe have to set portrait only in project settings for example..
This is happening on iPads and iphone 6+ only.
Hope this helped..

Related

iOS launch screen will appear in portrait instead of landscape

I am creating an iOS app that will support iPhone and iPad in landscape and portrait orientations. I have setup my launch screen storyboard with an ImageView and that appears correctly in both landscape and portrait modes in Interface Builder. However, even though I am holding my phone in landscape, the launch screen will always appear in portrait. I have logged my device current orientation in application didFinishLaunchingWithOptions, but it reports UIDeviceOrientation unknown. After the launch screen disappears, the first view appears in landscape as expected.
Do you know why that happens and how to fix it?
Thanks
I think that you haven't open this:

Orientation issue with iPhone 6 and iPhone 6 Plus

I have an iPhone application who need to run on iOS 7 and iOS 8. It's a full Portrait Application, except for the video player who is displayed thanks to a presented ViewController.
When I start the application from the landscape mode on an iPhone 6 or 6 Plus, It will cause to destroy the HomeView. All the orientation are supported in the project because of the video player (I know I can avoid the problem by removing the landscape support but my video player won't be displayed properly).
So the question is : How can I do to start my application from landscape mode without break the HomeView (so in a nice portrait mode) but at the same time still have my video player properly displayed in landscape mode ?
PS : I can't post screenshots, so when I say "destroy", just imagine the view with not well positioned and scaled elements.
How can I do to start my application from landscape mode without break the HomeView (so in a nice portrait mode) but at the same time still have my video player properly displayed in landscape mode ?
How the application is oriented on launch depends on the order in which the supported orientations are listed in the Info.plist file. Just make sure that Portrait comes first.
How the home view can be oriented depends on the root view controller's implementation of supportedInterfaceOrientation. Make sure that it returns UIInterfaceOrientationMaskPortrait.
In Info.plist set device orientation just to Portrait
In AppDelegate add -
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskAll;
}

Why is the orientation wrong at app start?

I'm working on an iPhone app that supports both Portrait and Landscape orientations. When I start the app in Landscape mode and verify the orientation in the AppDelegate it returns Portrait orientation. After I rotate the device/simulator it returns the orientation correctly. It's an iOS 7 app. Anyone know how tot handle this? I need to know the orientation at startup for handling the UI.
UIViewController documentation says:
Note: At launch time, apps should always set up their interface in a portrait orientation. After the application:didFinishLaunchingWithOptions: method returns, the app uses the view controller rotation mechanism described above to rotate the views to the appropriate orientation prior to showing the window.
That's why it returns portrait mode first. More info in UIViewController documentation.

iPad orientation issue when device is in flat mode

Actually I develop one iPad application. It works fine as desired. But I have orientation issue when initially application launch. Actually i put iPad flat in landscape(Horizontal) style. Now every time when application launch it will open in portrait mode. I checked with supported orientation style and other things also. I put the log in ViewDidLoad for 3 orientation, 1) viewControllerOrientation - portrait
2) ApplicationStatusbarOrientation - portrait
3) DeviceOrientation - Flat.
Now i have trouble even device is in flat mode (it really put like Horizontal) not in portrait, though why always it open in portrait mode.

iPad app to start in landscape mode

I searched for other existing posts, but none of them satisfied my requirements.
Here is the problem i face,
My app supports both the Modes , landscape and portrait.
But my first screen only supports Landscape , so the app must start in Landscape.
I have set supported Orientation to all the 4 options
I have set the Initial interface orientation to Landscape (left home button)
In the view controller of the first screen i am defining the below
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortrait);
}
And when i start the app the simulator always opens in Portrait and my view is all messed up in the portrait mode , since it is designed only for the landscape.
After the switch to the Landscape, the device remains in this mode.
can anyone help me with the solution to avoid this ?
Thanks
Naveen
EDITED :
This info may be helpful , The problem is faced only when i hold the device in Portrait and then launch the app.
Its not the duplication of this question, Landscape Mode ONLY for iPhone or iPad
Landscape Mode ONLY for iPhone or iPad
I do not want my app to be only in Landscape , i want only the first screen of my app to be only in Landscape.
I did some experimenting with an app I'm working on that has the same requirements, and came up with the following:
To set the initial orientations that are supported when the app is first launched, use the "Supported Device Orientations" setting for your target.
Also back that up with the appropriate shouldAutorotateToInterfaceOrientation code, as you've already done.
For subsequent screens, simply use the shouldAutorotateToInterfaceOrientation code to determine which orientations you want to support. Even if you've specified only landscape modes for the Supported Device Orientation, shouldAutorotateToInterfaceOrientation wins. :)
I think this approach is a little cleaner than using an extra dummy VC.
I achieved a workaround for the Problem and it solved ,
I created a dummy view controller and added as the root view controller of the Window.
Added the below method in the implementation
-(void)viewDidAppear:(BOOL)animated
{
WelcomeScreen *welcomeScreen = [[[WelcomeScreen alloc] initWithNibName:#"WelcomeScreen" bundle:nil] autorelease];
[self presentModalViewController:welcomeScreen animated:NO];
}
Now it worked as expected.
Here is a SO link that will hopefully answer your question on how to launch your app in landscape mode.

Resources