I'm developing an iOS app only in landscape mode. I'm loading the Launchscreen images as : Default#2x.png, Default-568h#2x.png, Default-667h#2x.png, Default-736h#3x.png.
The problem is that whenever i launch the app in iPhone6 or 6+ it gets the screen dimensions from iphone5.
P.S. I've tried using Images.Xcassets but it did not worked for iPhones<6.
Thanks.
Read iOS Human Interface Guidelines provided by Apple and confirm all your images are in required sizes or not. Also go through image naming conventions are approprite or not.
Because Launch Images should be picked up automatically as per device and its orientation.
Here is the link:
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html#//apple_ref/doc/uid/TP40006556-CH27-SW2
If your app is landscape only you MUST check option 'Portrait' on 'Device Orientation' section in General tab of app settings. Then you need setup orientation settings for all view controllers:
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft |
UIInterfaceOrientationMaskLandscapeRight;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
In Images.xcassets you need to put all images for iOS 7 & 8. After that app will be launched with proper launch image. Note that preferredInterfaceOrientationForPresentation must be equivalent for launch image orientation.
Related
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
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.
I'm developing a universal iOS app that only supports portrait and upside-down interface orientations. When supplying the launch images in Xcode, I see that I have warnings for landscape orientations, even having only portrait and upside down enabled in device orientations settings. Does this mean that I need to supply landscape launch images anyway? I don't find this clear in Apple's documentation.
Thanks
No. These are warnings. Apple would prefer you support all orientations on iPad, and recommend you do, but they do not require it. (Yet)
Launch Images in Landscape Orientation is optional and xCode ignores it if it is not provided in Application.
However, If you are using Xcode5 there will be a folder named Images.xcassets > Launch Images > There will be a blank icon available for iPad Landscape > Right Click on those 1x and 2x icon > Remove Selected Items.
This will remove the warnings that you are having in your case.
Let me know if that helps.
an iPad app includes at least one launch image in portrait
orientation and at least one launch image in landscape orientation.
Seems like a simple thing to do right? Go to the Target's Summary tab and set "Supported Interface Orientations" to Landscape Right only. You would think that would mean the app would be landscape only. But no.
On a device running 5.1 for example, if you open the app and hold the phone in the correct landscape right position you will see the view rotated 90 degrees counterclockwise, as if it think it's supposed to be in portrait mode, unless you add something like this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
But that only works for one view controller, and who knows if it works on all OS versions.
So how do you make an app landscape only? Do I have to add that code to every single view controller in the app? I do not need any rotation. All my views are designed in Landscape. I just want the app to open in Landscape Right mode and stay that way. And I want to support iOS 5 and up.
There are new methods introduced that you have to implement along with the old one they are as below
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
In Xcode you can navigate to your project settings -> summary -> iPhone/iPod deployment info. Here you can select the supported interface orientations. You can also edit the 'Supported interface orientations' array in your application's info.plist by adding the desired interface orientations application wide.
In the info.plist put the orientation to landscape
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.