Reputation: 4177
I searched for other existing posts, but none of them satisfied my requirements.
Here is the problem i face,
-(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.
Upvotes: 2
Views: 9681
Reputation: 59173
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.
Upvotes: 5
Reputation: 4177
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.
Upvotes: 1