在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元素?
注意:我已将子视图位置从原始位置更改
答案 0 :(得分:0)
[self.subView setNeedsDisplay];