iPhone Game Landscape Orientation Issue - iphone

I am trying to make a simple iPhone game and I need the game to be in landscape mode. I can get the initial view to be landscape, but if remove the initial view and replace it with a new view (going from Main Menu to Game Screen) the new view is now in portrait mode. Also, if I switchback to the first view (removing the game screen and then creating the new menu view) the view is still in portrait mode. I have the Info.plist file set up correctly to initialize with landscape right and I have the GameViewController.m file set up with the following code:
-(BOOL) shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
I have read many postings about people having troubles with setting up the landscape orientation, but they always seem to be about the initial load of the app (only displaying one view). I can't seem to find any solutions for this problem. Can someone help me?

You have stumbled on to
one of the most famous bugs on the platform!
Congratulations for spotting it! Here:
iPhone app in landscape mode, 2008 systems
be sure to read the paragraph that begins: "An important reminder of the ADDITIONAL well-known problem at hand here......." !!
It gives you the solution, which is used in all apps.

Make sure that all the view controllers that are visible on screen support the landscape orientation. I would recommend, in your shouldAutorotateToInterfaceOrientation, to return UIInterfaceOrientationIsIsLandscape(interfaceOrientation); instead of your code. This will ensure that both landscape orientation will work. Can you share a bit more how you are switching from the main menu to the game screen?

Related

Making a UIView landscape

I have created an iPhone app, which is a tab bar application and only in portrait orientation.
From one tab I am presenting a modal view which contain UIImage view.
Can I make landscape orientation only to that view while rotating iPhone to 90 degree?
yes , you can.
There are a few settings, code part which need to make it.
Depends also for which version, hopefully aren't targeting all supported by xcode, because it is horrible. Better choose only one, like the lastest iOS.

iPhone App on iPad not responding to touch at first start

If my iPhone App (not universal) starts in landscape mode on my iPad (3rd gen) it does not respond to any touch until I either press the 1x/2x Button or change the orientation. After that it works as normal.
If I start it on my iPhone 5 in landscape mode, it works like a charm.
shouldAutorotateToInterfaceOrientation gives a YES in every View, so I think that's not the problem here.
The first View is a tabbar-view.
I have the same problem too on my iPad mini with iOS6.0.1.
What I do to solve the problem is to set the Supported interface orientations to all off in the info.plist.
Next, add the Supported interface orientations (iPad) in info.plist and only add the Potrait (bottom home button) in it.
It should make no difference to the apps orientation provided that you set it properly in the view controller.
Also, make sure you set a correct initial interface orientation.
It then solves my problem.
The above answers are a bit difficult, especially when using Xamarin. This answer does work:
from another question:
iphone app doesn't respond after starting in landscape orientation on iPad
The comment of Daniel Sandland did solve it for me:
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
in didFinishLaunchingWithOptions,
(the C# variant for Xamarin)
I think this can be the problem of positioning of UI controls present on your screen.
The controls might be having auto positioning parameters (in XIB) may have been set in such way that the controls goes out of screen.
Try to correct resizing parameters in XIB.

Rotation in iOS6

There are many questions and answers about the changed rotation in iOS6.
But I have really not solved one problem about that.
Using Xcode 4.5.2.
If I do not set anything in the info.plist or by the buttons “Supported Interface Orientations”, the app will rotate between portrait and landscape depending of the device rotation.
Now I mean the rotation caused by how holding the device, not a default orientation when opening a ViewController.
I know how to prevent landscape mode
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait);
}
but it does not have any effect.
Yes it has effect if I add a FlipsideController from the NavBar. In FlipsideView the code above prevents the rotation.
In the other ViewControllers it does not have any effect at all, whatever code I write.
Take a Sample given by Apple, UICatalog.
Can anybode give me a hint how to controll the rotation for the whole table and also for a separate ViewController using code and not by the Buttons or info.plist which only gives a result for everything together which is not very practical for all views.

UI Page controller adjusting to just landscape mode XCODE

recently I found a project with a page view controller which I really liked and decided to use in my own project.
http://www.wannabegeek.com/?p=168
The problem is, The page controller starts out in portrait and has an auto rotate feature to landscape. For my purposes, I don't need any auto rotate feature, I just want to be able to swipe back and forth between views in landscape mode only.
I tried changing the code, but was unsuccessful in making it landscape only, If someone could help edit the code to NOT auto-rotate, start in landscape, and stay in landscape that would be great!
Thank you.
You have to perform 2 changes :
set Initial Orientation to Landscape ( either Home button left / right )
set - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation to return NO
Lemme add more detail to Shivan's answer:
Select Landscape Left and Landscape Right in target. Tap on the project to get to this page.
2.In the ViewController.m look for shouldAutorotateToInterfaceOrientation, make it return NO. See the following code.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return NO;
}

Can you tell which image the iPad has displayed at app launch? (or, I'd like to know the orientation if possible)

There are a number of similar questions on this site about discovering the orientation of the device in applicationDidFinishLaunchingWithOptions being problematic, but I've yet to find a working solution. The problem I have is that I am adding a full screen image (identical to the currently chosen Default-XXX.png being displayed by the OS to my main window. I do this in order to have an animation happen from the 'splash screen' to my first view controller's view.
Works great, except the device keeps telling me that it is portrait mode - meaning I can't match the image being displayed consistently, since I have different graphics for each orientation)
My understanding is that all apps default to portrait orientation until a rotation occurs inside the app (usually when presenting a viewController) but I'm not 100% convinced.
You should be able to solve this using a view controller. When the application has finished launching, present a view controller in the window. Override the shouldAutorotate… query so that the controller autorotates to portrait/landscape and when you receive one of the rotation callbacks, update the image in the view accordingly. The controller will start up in portrait, but if the device is in some other orientation, the rotation callback will immediately follow and you will get the correct image.
P.S. You might find the Orientation Zoo project helpful when debugging this.