Force rotate in objective-c - ios

So I know objective-c is no longer being updated and is kind of left behind now but I'm still learning on how to code so it is perfect.
I have an app that I am creating with menues in portrait and the main game is in landscape. I have made the ViewControllers into landscape and when turning the device into landscape it works perfectly but when the device is kept in portrait the game is all messed up.
Could anyone help me with how to force rotate/make the game wait until the screen is portrait? The game looks really messed up portrait so I would prefer if the screen was forced to rotate.
Thanks

In the view controllers that need their orientation updated, add:
[UIViewController attemptRotationToDeviceOrientation];
in their viewDidLoad.

Related

iphone keyboard is rotating into landscape while app setting is portrait only

My app’s device orientation is set to portrait, however when rotating the device into landscape mode, the app is keeping its portait mode but the keyboard is rotating into landscape mode...Something that is unexpected.
Why is that happening and how to prevent it?
Thanks
Jrejory
After not getting any answer and making more researches, I came across this Answer:
https://stackoverflow.com/a/6941930/4400274
Because I just needed the portrait orientation in my app the following worked for me :
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
I put that in my main Navigation Controller's viewDidLoad.
I know it's late. But maybe it will help someone else. I had the similar issue. My app should support portrait orientation for iPhone and all orientations for iPad. So, on the iPhone scene didn't rotate, but keyboard did. All my UI was made from code, I also init view controllers (including root) through code. But I didn't remove default Main.storyboard file. When I removed string in Target -> General -> Main Interface, it help me. It was not obvious.

UISplitViewController master slide in only works after rotation

I am working with a UISplitViewController, and the master is set to be hidden on portrait orientation. In that orientation, the app should open the master view controller with a swipe from left to right gesture.
The problem is that this is not happening unless I rotate the device. If the app starts on landscape, I change to portrait and it works properly (since one rotation was made). If the app starts already on portrait, I need do change to landscape then back.
How can I make it work since the app is opened?
That seems to be the default behavior. Re-setting the delegate upon rotation seems to fix it.

UIImagePickerController landscape wrong orientation

I have a problem with UIImagePickerController on my iPad. it is presented as a modalView (presentViewController:).
All orientations are allowed and should work.
If I push a ViewController in Portrait mode on this VC (this is the main view of the App), go back to the Springboard, rotate the iPad to Landscape mode, reopen my App, There is a big black space on the screen.
However, the camera controls are well shown.
Has anyone already seen this kind of bug?
Thank you.
This is better with a screenshot

Diagnose rotation problems on iPad

I am having a weird problem with keeping orientation on the iPad. Very rarely, when I swap in and out view controllers, my view is displayed as portrait, even though my device is in landscape mode.
What should I do to resolve this problem? I have already set my controllers to landscape using shouldAutorotateToInterfaceOrientation: method. Also, it appears only very rarely, making tracking the bug very difficult.
Is there a faster way to find out why the orientation is wrong, besides going through each controller?
I see your comment that you are managing orientation by code using "shouldAutorotateToInterfaceOrientation", that is specifically an iOS5 method. By any chance is the iPad iOS6? If it is, you need to back it up with "supportedInterfaceOrientations".

Landscape orientation for iPad?

Frustrated by how simple this should be...
I'm trying to add landscape support to an existing iPad app of mine. Do I actually have to create a completely new view controller for landscape mode? (surely not as that is a complete pain!)? Or can I use the existing view controllers and design for landscape and portrait? The simulated metrics thing doesn't work because whenever I make changes in a view controller in landscape mode and switch back to portrait it messes everything up! I know how to switch the view to landscape programmatically, this is (at least i think) an 'interface builder' sort of issue.
Why is this so difficult to do/hard to find!? Might be worth mentioning I'm using Xcode 4.2 with storyboards rather than separate xibs. Surely I don't have to use a separate view and segues because I really can't be bothered wasting my time with that.
Any help would be nice! Thanks
Watch for -willRotateToInterfaceOrientation:duration: and change the frame of your interface elements when the rotation changes.

Resources