how to solve orientation issue in ios7?

user2798258 picture user2798258 · Nov 6, 2013 · Viewed 6.9k times · Source

I am working on orientation in ios7

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return YES;
}

/**
 Changing frame depending on mode
 @param interfaceOrientation is UIInterfaceOrientationobject
 @param duration is NSTimeInterval object
 */
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
        toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        [self landscapeViewFrame];
    }
    else if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        [self portraitViewFrame];
    }
} 

where landscapeViewFrame contains code for landscape View (frames) and portraitViewFrame contains frames for portrait View.These methods used to work, but after upgrading to ios7 they are not responding and not been called, I googled and found these methods are no longer supported.I have tried the other methods

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;//UIInterfaceOrientationIsPortrait(UIInterfaceOrientationMaskPortrait|| UIInterfaceOrientationMaskPortraitUpsideDown);

}


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    if (self.interfaceOrientation == UIInterfaceOrientationPortrait)
    {

    }
    else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight){
    return UIInterfaceOrientationMaskAll;
    }
}

but only shouldAutorotate is called the others are not called . Which methods should be replaced in place of those two. Which method should be used/replaced for willAnimateRotationToInterfaceOrientation. please help me.

Answer