在“旋转”上放置和移动视图不会重绘子视图的UI元素

时间:2013-02-25 16:03:17

标签: iphone ios objective-c

在iOS中,在“旋转”上放置和移动视图不会重绘子视图的UI元素(按钮和标签), subView是主视图的子视图

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{

    if (UIInterfaceOrientationIsPortrait(fromInterfaceOrientation)) {
        self.subView.frame = CGRectMake(0, 0, 100, 200);

    } else {
        self.subView.frame = CGRectMake(0, 0, 200, 1000);
    }

    self.subView.contentMode = UIViewContentModeRedraw;
    [self.subView setNeedsLayout];
    [UIView commitAnimations];
}

如何重绘subView的UI元素?

注意:我已将子视图位置从原始位置更改

1 个答案:

答案 0 :(得分:0)

[self.subView setNeedsDisplay];