iOS app starts in landscape mode - objective-c

I have a strange problem. My app keeps starting in landscape mode. If I open it in simulator it rotates to landscape mode automatically. When I start it on iPhone it firstly starts in landscape mode and then shortly after it rotates to correct position. I have set "Initial interface orientation" in .plist to portrait, but that changed nothing.

I had the same problem. If you go to your Supported Interface Orientations you'll see
Item 0 ...
Item 1 ...
And so on.
If you edit this list so that Portrait (bottom home button) is the first item in the list then your app will open in portrait mode. You can still support other orientations as items 1 thru 3.

go to your supported device orientations and check if you have portrait mode selected

if you only support Landscape, write code
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
it work for me.

In XCode 6.4, I just unchecked all 4 of the device orientations and reselected them starting with portrait in the Deployment Info for the Target app. Apparently the order that they are checked here controls the order of the values in the plist file.

Related

Adding iOS 7 version of iPhone 4-inch launch image to project breaks launch image when run on iOS 7

I'm running into a problem on our landscape only app that targets iOS 6 and 7. Xcode gives me the following warning:
An iPhone Retina (4-inch) launch image for iOS 7.0 and later is required.
If I add the required images, when I launch the app on iOS 7, I get a black launch image shown. On iOS 6, it displays correctly. But without the images, it works just fine on both iOS 6 and 7.
I am already using Asset Catalogs in this project, so I don't think that's an issue.
I would really like to get rid of this warning, but I haven't been able to figure out a way around it.
XCode is looking for Portrait orientation for iPhone. You need to provide it for the launch image, but don’t let your application to rotate when device is in Portrait mode.
In order to do this you need to do the following:
Go to General -> Deployment Info -> Device Orientation. Deselect Landscape Left and Landscape Right. Select Portrait, then Landscape Left and Landscape Right, order is important!
Add the following function to your code (if not yet):
-(NSUInteger)supportedInterfaceOrientations
{
return (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight);
}
That’s all!
In my case (landscape only app), I was able to fix it by doing the following:
adding portrait to the supported orientations for the iPhone in my Info.plist
replacing shouldAutorotate: methods with supportedInterfaceOrientations and preferredInterfaceOrientationForPresentation in my view controllers.
added application:supportedInterfaceOrientationsForWindow: to my app delegate.
Also I had to make sure that in the Info.plist that the portrait orientation was listed first. Xcode had added it to the end of the list, but if it was there, it would still be a black display on launch. Moved to the top, it was properly detected by iOS when the app was launching.
LaunchImage import a 640*1136 picture,
BTW, LaunchImage in Images.xcassets
sample picture

How to write code for landscape or portrait modes in windows 8?

How to write code for landscape or portrait through programatically.i need to set my app only run in portrait mode only.please tell me .
You can change it and make it run only in portrait in your package.appxmanifest file.
But please do note, this won't work on the emulator, or any other device without a hardware accelerometer.
More
Set SupportedOrientations , Orintation property to Portrait (in xaml).

Edits to app delegate to lock in portrait ios 5 and 6

I'm having a few issues with stopping rotation in both ios 5 and ios 6. I want to lock the app into portrait. I'm using a nav bar based application, but the nav bars on some pages are hidden (if that makes a difference).
I'm not quite sure what edits to make in the app delegate, to disable autorotation and lock it into portrait to target these versions of iOs, any ideas?
Have you checked .info plist file?,if not then see supported inteface orientation and discard orientations which you don't want in your app.

Start iPad application both in landscape and portrait mode

Right now when I start my iPad application, if I'm turning my device in landscape mode then my rootConroller automatically turns my table from portrait to landscape mode. The problem is that it does so by animating the transition. Instead I would like the app to start in landscape mode right away. I've also created an image called Default-Landscape.png which is ignored, so I suspect I have to tweak something in the plist file?
Set your orientation to UISupportedInterfaceOrientations in the Info.plist file

iPad application always opens in portrait mode

The app uses a UISplitView and it always opens in portrait mode. If the iPad is held horizontally it will open in portrait mode and then rotate to landscape. I'd like it to just open up in landscape mode without needing to rotate. Any ideas>
In Info.plist, set UIInterfaceOrientation to UIInterfaceOrientationLandscapeRight (or Left). See the Information Property List Key Reference for more details including how to have different orientations for iPhone versus iPad.