kiri
kiri

Reputation: 2007

Upside down Orientation issue in iOS6

I am creating a sample empty application and added UIViewController class,

Below is the code in the App delgate

TestViewController* viewController  = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];

UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:viewController];

[self.window setRootViewController:navController];

Now i am rotating the App but in the UPsidedown Orientation Navigation bar is not Rotating I am attaching a screen shot

enter image description here

Then Added a the Below Method in App delegate

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{


    return UIInterfaceOrientationMaskAll;
}

And in the Class i have added following methods

-(BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskAll);
}

In the Summary i have activated all the orientations can any One tell me the Solution for it

Upvotes: 1

Views: 433

Answers (4)

Vinay V Devdikar
Vinay V Devdikar

Reputation: 839

`TestViewController* viewController = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];

[self.window setRootViewController:viewController];`

remove the navigatioan bar from appdelegate and then check

Upvotes: 0

Deepesh
Deepesh

Reputation: 8053

1) just You created a category for UINavigationController class and I defined these methods

In CustomViewController.h

#import <UIKit/UIKit.h>

@interface CustomViewController : UINavigationController

@end

In CustomViewController.m

#import "CustomViewController.h"

@interface CustomViewController ()

@end

@implementation CustomViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(BOOL) shouldAutorotate{
    return YES;
}

-(NSUInteger) supportedInterfaceOrientations{

    return UIInterfaceOrientationMaskAll;
}

And AppDelgate.m file

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

     self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];

    CustomViewController *navController = [[CustomViewController alloc] initWithRootViewController:self.viewController];
    // Override point for customization after application launch.

    self.window.rootViewController = navController;
    [self.window makeKeyAndVisible];
    return YES;
}

2) And check Orientation In Target enter image description here

3) Change the class from UINavigationController to the CustomViewController in my XIB in IB

4) Reset the Simulator and run the code, I think your problem will be solve.

Upvotes: 1

shingo.nakanishi
shingo.nakanishi

Reputation: 2797

Upside Down button to ON in Supported interface orientations on Xcode

http://www.appcoda.com/ios-game-tutorial-maze-part-1/

Upvotes: 0

Fonix
Fonix

Reputation: 11597

i think you need to use

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return TRUE;
}

instead of shouldAutorotate

Upvotes: 0

Related Questions