如何解决ios7中的方向问题?

时间:2013-11-06 13:22:47

标签: ios iphone ios7 ipad-2

我正在 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];
    }
} 

其中landscapeViewFrame包含横向视图(框架)代码,portraitViewFrame包含纵向视图框架。这些方法用于工作,但在升级到ios7 之后它们不是响应并且没有被调用,我用Google搜索并发现这些方法不再受支持。我已经尝试了其他方法

- (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;
    }
}

但仅调用shouldAutorotate,而不调用其他willAnimateRotationToInterfaceOrientation。应该用哪种方法代替这两种方法。 {{1}}应该使用/替换哪种方法。请帮帮我。

0 个答案:

没有答案