I've written an app that supports only landscape mode. For some reason, it is being very stubborn. It launches and runs great on the simulator, but when I go to launch it on my device, it will not launch or rotate to landscape mode at all. I'm running 5.1 on my iPad, and using Xcode 4.6.2. Here is everything I've tried after searching on this site for a solution:
Edited my -info.plist and deleted support for portrait mode in the supported orientation interface options
In the projects target, in the supported interface orientations I highlighted only landscape left and right
3 Added:
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
To my only ViewController file. It runs in landscape only on the simulator, but is being very difficult on my device. Does anyone have any ideas?
Check this tech note, it describes the opposite of your problem but the resolution is the same.
Related
I have an iPad kiosk app that displays video on an external monitor connected via an HDMI cable. The device orientation is set to Landscape Left or Landscape Right in the apps general settings. I want the app to be displayed in landscape on the iPad and on the external monitor. When I run the app in iOS7 the external monitors view controller is displayed correctly in landscape orientation, but when run under iOS 8 the external monitor's view controller is rotated 90 degrees counterclockwise, into portrait orientation.
How do I force the external monitor to the correct landscape orientation? What has changed between iOS 7 and 8 to cause this behavior?
I've had a similar issue with a landscape-only iPad app that supports airplay. On the iPad screen, everything was working fine, but on the external display, starting # iOS 8.0, orientation issues started happening. I tried many things, what ended up helping was these two fixes:
On the shouldAutorotate method of your ViewController, return NO.
Implement the application:supportedInterfaceOrientationsForWindow: method:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)_window
{
if ([UIScreen mainScreen] == _window.screen || !_window)
{
return UIInterfaceOrientationMaskAll;
}
else
{
return UIInterfaceOrientationMaskPortrait;
}
}
The second part of the fix may require some changes on your side, since you're not using AirPlay, but I hope it can help lead you to the right solution. Good Luck!
I made an ios app which is working fine in the iPhone in both mode either it is landscape or portrait by using the autorotation methods i used the following code
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
self.view=Landscape;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (90));
self.view.bounds=CGRectMake(0.0,0.0,480.0,320.0);
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
self.view=Landscape;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (-90));
self.view.bounds=CGRectMake(0.0,0.0,480.0,320.0);
} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
self.view=Portrait;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (0));
self.view.bounds=CGRectMake(0.0,0.0,320.0,480.0);
} else
{
self.view=Portrait;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (180));
self.view.bounds=CGRectMake(0.0,0.0,320.0,480.0);
}
}
But for the iPad its work only in one mode either landscape or portrait when i rotate the device it shows the blank white screen but if i don't rotate that it works pretty fine.
Kindly guide me as i am new to the iOS.
One place to check would be on the Application target, general tab, Deployment info section.
Just below the Deployment Target and Devices selectors, you can switch between iPhone and iPad, then enable supported orientations with the checkboxes.
If you already have these setup correctly for both iPad and iPhone, then you'll probably want to look at how you've handled the supportedInterfaceOrientations or possibly the preferredInterfaceOrientationForPresentation methods of your UIViewControllers
I read up Landscape Mode ONLY for iPhone or iPad and followed the steps, the app opens up in landscape mode but whenever i reallocate the view, it again comes up in the portrait mode. I have kept Landscape right as the only supported resolution and have overridden the souldAutoRotateToInterfaceOrientation as well. I am working on iOS 5.1.
Thanks.
Code:
-(BOOL) shouldAutoRotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
I'm creating an iPad application that supports ONLY LANDSDCAPE mode. I'm using storyboards.
Even after doing the below, while the simulator starts up in the landscape mode, the application starts up in the portrait mode only. Pls help in how can I make the application start up in landscape mode and retain that mode throughout.
shouldautorotate is set YES for landscape
initial interface orientation in info.plist is set to landscape
supported interface orientation in info.plist is set to landscape
simulated metrics for viewcontrollers are set to inferred.
thanks in advance for the help. I've searched on the web but the answer to this is not available.
Under simulated metric choose "Landscape".
Also make sure you have this method in your view controller implementations:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
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.