- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
CGRect apprect;
apprect.origin = CGPointMake(0.0f, 0.0f);
if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight))
apprect.size = CGSizeMake(480.0f, 300.0f);
else
apprect.size = CGSizeMake(320.0f, 460.0f);
// 设置当前控制器所有的sunView的位置
float offset = 32.0f;
for (UIView *subview in [self.view subviews])
{
CGRect frame = CGRectInset(apprect, offset, offset);
[subview setFrame:frame];
offset += 32.0f;
}
}
本文介绍了一个iOS应用中处理屏幕方向变化的方法。当设备旋转时,通过调整UIView子视图的位置来保持良好的视觉布局效果。具体实现了不同方向下视图尺寸的变化,并为每个子视图设置了合适的frame。
14

被折叠的 条评论
为什么被折叠?



