xcode 4.2.1 - rotation support issue - iphone

I have designed an app to support ios 4.3 and from "Supported Device Orientations" I removed everything and only portrait is active.
The problem is that when I simulate the app in my phone it supports all the orientations and my app looks missed up with the landscape orientations.
how can I force it not to support landscape orientations?

In your view controller call
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
to force it not to rotate in landscape mode. You will also need to make sure all of your parent views have autoresizesSubviews = YES.

Related

Universal project: how to make landscape start-up in iPhone and portrait in iPad

I have an universal project, and want to keep landscape from very beginning of star-up for iPhone and portrait for Pad. How can I do it?
That's not possible. iPhone apps always have to start in Portrait orientation. Any game you see that has landscape-only display is still starting showing a portrait default image and the root view controller then can be landscape-only.
On iPad you can restrict the app orientation to Landscape and also have it start in Landscape.
The iPhone restriction is enforced by Apple and they won't approve an iPhone app that restricts itself to Landscape start.
If the device is already in landscape position it will start as landscape, but if you want your program to work always in landscape position and never flip to portrait, you have to set the orientation to landscape in each class you create:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscape || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}

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.

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?

How to change already developed app into both orientations Landscape and portrait?

I developed app(navigation + tabbar) in portrait mode.
But now I want that if user change its orientation to landscape or
portrait then all should be rotate in that orientation.
You need to set each view's control autoresizingmask. You can do it through xib as well as code as per your need and add below method in all viewControllers and it should work.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return YES;
}
Hope this help.
And have a look into your ".plist", you can define "Supported interface orientations" (UISupportedInterfaceOrientations) here.

Forcing rotation to landscape

I would like my app's rotation to be fixed as landscape...
I've done some research, but most posts are about detecting change,
and I couldn't find any about forcing one.
Could anyone help me?
Try this
In plist change the Supported interface orientations to Lansdscape
OR
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); // home button on right
}
All the best
You can change the info.plist of your project so that you app always shows Landscape initially.And then you can make your view controller's to support only landscape orientation.
hope this also helps
Only support for landscape Interface orientation
Launching application in landscape orientation for IPad