如果我正确理解你的问题,你可以使用的方法willRotateToInterfaceOrientation:duration:
在UIViewController中。
之后你可以用IB 2个UIView的变量,将它们设置连接:
IBOutlet UIView *view1;
IBOutlet UIView *view2;
然后,在willRotateToInterfaceOrientation:duration:
可以交换意见。假设你的ItemController是的UIViewController的子类,你可以有这样的事情:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[self setView:view1];
}
else {
[self setView:view2];
}
}
当用户旋转iPad的这种方法会自动调用。
注意:请确保将shouldAutorotateToInterfaceOrientation:
设置为返回YES
,并且您可能必须检查方向以将视图属性设置为最初的正确视图。
编辑:我的答案是假设你有不同的布局/元素的两个视图,而不是两个视图基本上为不同的方向大小相同的事情。如果后者是这种情况,那么只用一个视图就可能有更好的方法。