Supporting certain orientations only not working in iOS 7? - ios

I can't simply uncheck in the Deployment Orientation section because i have a view that must be viewed in landscape mode, and when I leave landscape mode unchecked while it works in the first few view to keep my views only portrait, when I get to the view that forces it to be landscape it crashes.
So with that being said, all orientation possibilities are checked on the Deployment Information and I am using the following code to keep my views portrait:
- (NSUInteger) supportedInterfaceOrientations {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
else
{
return UIInterfaceOrientationMaskAll;
}
}
The problem is, that this does not seem to be working in iOS 7, or in the iOS 6 simulator for that matter, although it works well in my physical iPhone with iOS 6, but again, not on the iPhone with iOS 7.
What can be a solution to this problem?

Related

ViewController orientation on external monitor

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!

iOS+SpriteKit: How to force portrait mode?

I'm currently working on a SpriteKit game for iOS 7+ and XCode 6. The game should always be presented in portrait mode. So far I have implemented these methods in my view controller:
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
This works fine as long as I start the app holding my iPad in portrait mode. It does not switch the orientation during game play.
But when holding the iPad in landscape orientation during the app is starting, the game is shown in landscape.
How do I force the app to be shown in portrait mode even if the device was held in landscape mode during startup ?
To solve the app orientation issue
Go to your projects plist file (should be "YourApp-Info.plist")
Add a row and enter "Supported interface orientations"
Add the orientations that your app supports

Universal app orientation issue

My app was originally created for iPad, in Landscape orientation. Now I've to make it compatible with iPhone.
Converting Storyboard from iPhone to iPad
I followed this thread to copy my storyboard and define it for iPhone. In the project settings, I defined the new story board for iPhone, in Portrait mode. In the new storyboard, I changed every viewController to set in Portrait mode.
When I launch the App on iPhone (simulator or device) It's still in landscape mode but with the changes (moved fields, for exemple) I made in the new storyboard.
Did I forget something?
Thanks :)
This started happening with the new xCode for universal projects... go to your .plist file for the project and you will find a field for orientation for iPad (1 item) and orientation for iPhone (4 items), expand the iphone one and remove the rows containing orientation you don't want. Save, clean, and build.
Don't search anymore, i found the solution.
In the app I've to access to the Camera Roll.
On the iPad, if I access it in landscape mode, the Camera Roll opens in Portrait, and it's ugly and annoying for the user.
Then someone on Stack suggested to use a Category UIViewController+OrientationFix.h
Here is the code...
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
I had to modify it
NSString *deviceType = [UIDevice currentDevice].model;
NSLog(#"Device Type : %#", deviceType);
if([deviceType hasPrefix:#"iPad"])
{
return UIInterfaceOrientationMaskLandscape;
}
else
return UIInterfaceOrientationMaskAll;
The strange thing it that I didn't found it by searching "landscape" in all the projet, even by ignoring case.

Iphone app is working fine in both landscape and portrait mode but in ipad it only works in one mode?

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

Allow only landscape mode in iOS app

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);
}

Resources