旋转的UIViews变得反应迟钝

时间:2012-07-13 14:52:34

标签: objective-c uiview uiviewcontroller rotation uiinterfaceorientation

我有一个UIViewController子类,当UI旋转时会改变它的框架(例如,最常见的是,框架大小相同,并且以横向和纵向为中心。)当视图旋转时,视图可视地将其框架更改为预期。但最终在新帧区域内的控件(按钮,滚动视图等)不会响应触摸。响应的唯一控件是保留在原始帧中的控件(因此,如果视图向下移动到左侧,控件或右上角控件的一部分保持响应。)知道这里发生了什么吗? / p>

以下是更改框架的代码:

- (void) setLandscape:(bool)bLandscape {

    if( bLandscape )
        [self setFrame:m_landscapeFrame];
    else
        [self setFrame:m_portraitFrame];
}

在直接处理旋转的大视图控制器中:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    bool bToLandscape= UIInterfaceOrientationIsLandscape(toInterfaceOrientation);

    [UIView beginAnimations:NULL context:nil];
    [UIView setAnimationDuration:duration];

    [m_pCurrentWindowViewController setLandscape:bToLandscape];

    // (Some unrelated stuff happens here...)

    [UIView commitAnimations];

}

对我来说,这似乎是一个错误,或者至少是苹果公司的糟糕设计 - 应该永远不会有一个视觉在视觉上处于一个位置而在控制方面处于另一个位置的时间。但我只是想找到一种方法来解决这个问题。

1 个答案:

答案 0 :(得分:1)

我找到的最简单的解决方法是在didRotateFromInterfaceOrientation中制作动画后更新willRotateToInterfaceOrientation中的帧。

相关问题