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