Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View controller is not rotating in iOS 7

My app works fine in ios 6.But when i upgrade my app to ios 7, view controller is not rotating.I have set rootviewcontroller to mainviewcontroller. self.window.rootViewController=mainViewcontroller; What change in ios 7 make my app to not rotating..?

like image 910
Maruti Avatar asked Nov 11 '22 22:11

Maruti


1 Answers

This the code I have tested in xcode 4.6 and xcode5-DP6

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
    } else {
        self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
    }
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];

    self.window.rootViewController = navigationController;//self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

In ViewController I have inserted below methods for testing

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    NSLog(@"rotated");
}

By using above code there is nothing problem in rotation. Its perfectly rotating in all directions.

Check your orientation methods to overcome this problem or post some code snippet.

Note: I have created sample appication in Xcode4.6.

like image 121
ajay Avatar answered Nov 30 '22 02:11

ajay