Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在旋转时放置和移动视图不会重新绘制子视图的UI元素_Iphone_Ios_Objective C - Fatal编程技术网

Iphone 在旋转时放置和移动视图不会重新绘制子视图的UI元素

Iphone 在旋转时放置和移动视图不会重新绘制子视图的UI元素,iphone,ios,objective-c,Iphone,Ios,Objective C,在iOS中,旋转放置和移动视图不会重新绘制子视图的UI元素(按钮和标签),子视图是主视图的子视图 - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { if (UIInterfaceOrientationIsPortrait(fromInterfaceOrientation)) { self.subView.frame = CGRectMa

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

- (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];
}
如何重新绘制子视图的UI元素?


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

Hmmm…奇数。首先,这些UIViewController子类是添加到视图还是UIView子类(请提供详细信息)?第二,您能告诉我们在哪里添加子视图的代码吗(或者它是在IB中完成的)?
[self.subView setNeedsDisplay];