iPhone supported orientations in Xcode - iphone

I've set in plist that it should only support portrait mode, but when I rotate it the view changes. It worked for me before, but not now...
Please help, it's driving me crazy!

Vedran Burojević,
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait)
}
the above code only support portrait mode..

you can write the code in this.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait)
}

Related

Supported orientation madness

I know this is the most commonly asked question and trust me I have tried every kind of combination to make this happen and went through most posts here on stack overflow.
I have a UINavigationController called v1ViewController and what I am trying to do is when it is shown to the user I just want it to either show in portrait or portrait-up-side-down modes, no landscape even if the user rotates the device in landscape it shouldn't do anything.
NOTE: I did highlight all options in Xcode for supported interface orientations as in one of my other view controller I need to show user something in both landscape and portrait modes but for this UINav Conrtoller I want it to just remain in portrait modes.
The code I have for iOS 5.0 work just fine without a problem.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
return YES;
}
else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
return YES;
}
else
{
return NO;
}
}
the headache I have is with iOS 6. No matter what I try and do it still lets the user rotate the bloody thing in landscape (see code and screenshots)
// *********************
// iPhone 5 orientation support
// *********************
- (BOOL)shouldAutorotate
{
UIInterfaceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
return YES;
}
else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
return YES;
}
else
{
return NO;
}
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
You need to ensure you override the base UINavigationController and assign a custom class to it(not just the viewController that is the subview for the UINavController..ie the view contained below the navigationBar). Inside the UINavigationController, return NO on shouldAutoRotate.

Orientation iOS storyboard don't rotate?

OKay, this is probably pretty noob, but I couldn't find how to solve it.
I dragged an iPad UIViewController to the storyboard and enabled the orientation to YES. But for some reason that view is not rotating. The status bar at the top is rotating but the view, tableview and labels inside are not rotating when you rotate the iPad. Anyone know why and how to fix it?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOr‌​ientation { return YES; }
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
//return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
//implement your code
return (interfaceOrientation != UIInterfaceOrientationLandscapeRight);
} else {
return YES;
}
}
I think it will be helpful to you.
The status bar rotating might mean that some modal segue was not dismissed properly just check. Also if its in a navigation controller make sure all views in the stack has been set to return YES.

Supporting orientations IOS

Hello i want to support portrait, home button up and down in my application how can i do that?
i go to my project settings check those two
and i add the code below
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
I also tried
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
but none seems to work
any help
Try this
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
if((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){
return YES;
}
return NO;
}
If it still doesn't work, you can try this (just for the sake of testing)
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return YES;
}
if this doesn't work, either you are not messing with the right view controller, or the parent/root view controller has rotation disabled (returning NO in shouldAutoRotate method of the rootVC)

Navigation Controller in landscape with Storyboard [iPhone]

I'm working with Navigation Controller in my storyboard, but my application is always in portrait format when I put the simulator in landscape. Why? =(
Change
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
To
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
Also make sure in your project settings you have 'Supported Device Orientations' set to allow Landscape.

Supported orientations not limiting actual orientations

I have an iPad game that I only want to see in landscape view. I have selected the landscape view from the target's summary and have the code
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
in my first viewcontroller which is added to a navController. But the only effect that I can see by changing the target's orientations is not how it can be rotated but rather what direction it is first loaded in. Does anyone have any ideas? Thanks!
Try this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}