UIDEVICE orientation - iphone

hello all i have my splash screen which i want to show in landscape mode and all other screen in potrait mode. My root view controller is acting as a splash screen i am writing this code in viewdidload method
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
But this code is not working and shows me that UIdevice may not respond to setorentation please guide me that how could i change the orentation for only first splash screen and also other screen should be in potrait mode

UIDeviceOrientation refers to the physical orientation of the device whereas UIInterfaceOrientation refers to the orientation of the user interface. You can't change the physical orientation of the device, but you can change how the status bar is displayed via [UIApplication sharedApplication].statusBarOrientation

Can't you just have a splash screen that is displayed sideways?
The user will interpret that as a "landscape" splash and adjust accordingly, whether or not your application actually thinks it is. Just make sure to return NO in shouldAutorotateToInterfaceOrientation: so it doesn't rotate away when the user turns it.
But a warning: it's probably worthwhile to tweak your splash screen so it is in the portrait orientation, since it may be annoying to suggest to the user that your app likes landscape, and then switch to portrait as soon as it actually starts.
If you really want to, though, you can use setStatusBarOrientation:animated: on the UIApplication to force the orientation.

Related

Change Keyboard Orientation Without Flip The iOS device

I want to make the iOS device in a portrait mode and any keyboard will show in landscape mode. How can I manage such a thing? Thanks in advance.
I would experiment with setting the status bar's orientation. This would require special handling to assure that your views won't rotate, but the keyboard, popovers, action sheets, etc. all take the orientation of the application's status bar. Set the status bar's orientation like so:
[[UIApplication sharedApplication] setStatusBarOrientation:newOrientation]

Programatic iPhone landscape orientation lock

The iPhone has a orientation lock for portrait only. So I added a landscape orientation lock button to my UI that sets a landscape_orientation_locked variable to YES or NO. Then in shouldAutorotateToInterfaceOrientation: I basically do the following:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (landscape_orientation_locked)
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
return YES;
}
This works fine, except for one case. When I turn the iPhone to landscape orientation, toggle the orientation lock button, rotate the iPhone to portrait orientation and hit the button again. The interface orientation won't change from landscape to portrait. The iPhone has to be turned into landscape and then portrait orientation to trigger the interface rotation.
So my question is: Can I somehow 'force' the iPhone to re-evaluate it's current orientation?
Presenting and then dismissing a mock modal view controller should force an orientation check.
EDIT: Found the question where I first read about that:
Is there a documented way to set the iPhone orientation?

Forcing a UIVIew to lay itself out for the current device orientation

I've been working on this for days and can't crack it. The sequence of events is:
In landscape (let's just say right), the user hits an "edit" button.
A portrait only modal interface slides in. Its shouldAutorotateToInterfaceOrientation returns yes only for portrait.
The device becomes convinced it is in portrait mode.
Problem 1: If the user dismisses the interface without having actually rotated to portrait mode, the device reports that is in landscape right orientation (which it is), but the interface is laid out in portrait orientation.
Problem 2: If the user rotates to portrait, the interface does not get laid out again.
Problem 3: (And this one is weird) Rotating back to the same landscape orientation (right) where the edit button was pressed causes the status bar to return to landscape, but nothing else changes. All my stuff remains laid out in portrait mode. Rotating to the other (left) landscape orientation works perfect.
I need some way to force the layout engine to redo the layout for the orientation the device is actually in.
UIView - layoutSubviews, - setNeedsLayout, and -layoutIfNeeded don't have any effect.
Thanks for any help.
Do what iBooks (2.x) does and force the interface orientation to portrait with
+ (void)attemptRotationToDeviceOrientation. This way, you nip the problem in the bud at step one.

UIImagePickerController differences from iPhone and iPad woes

I have an app designed for iPhone that makes use of the UIImagePickerController.
The app run in landscape only up until the image picker comes into view in its default portrait.
Problem 1:
On the iPhone when I rotate the device to portrait to view the image library the image picker view seems to do a flip as if rotating from landscape to portrait?
Problem 2:
I get the dreaded warning Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
Problem 3.
on the iPad when selecting an image the image picker is dismissed and the view is back in landscape but ...... if I then do anything that requires alert view or the keyboard they appear as if the device is in portrait? This does not happen on the iPhone???
I know problem 2 is a long running issue but please can anyone help with problems 1 & 3?
Thanks
number 3 resolved :-)
"The keyboard will show up in the orientation of the statusbar, which doesn't always change with rotations for some reason. So if you want to display that view only in landscape set [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft; or whichever orientation you want to prefer in your viewWillAppear method."

iphone - programmatically rotate system keyboard to landscape when device is in portrait orientation

I would like to do this because the keyboard buttons are slightly bigger in landscape mode than portrait and I will have older users using my app.
Does anybody know a way to do it??
Thanks.
The keyboard will show up in the orientation of the statusbar, which doesn't always change with rotations for some reason. So if you want to display that view only in landscape set [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft; or whichever orientation you want to prefer in your viewWillAppear method.