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后它们没有响应并且没有被调用,我用谷歌搜索发现这些方法不再受支持。我试过了其他方法

- (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。请帮我。

4

0 回答 0