【发布时间】:2012-03-08 13:26:47
【问题描述】:
我有一个 iPad 应用程序,它有 2 个视图,每个视图都有自己的视图控制器。苹果表示,他们建议 iPad 应用程序能够向各个方向旋转。我使用这种技术来定位我的故事板中的元素旋转变化:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
//[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
studentNumberButton.frame = CGRectMake(30, 1, 158, 155);
studentNumberLabel.frame = CGRectMake(173, 57, 347, 43);
studentLabel.frame = CGRectMake(528, 56, 67, 43);
// Other code goes below...
我为每个视图都这样做了,它适用于所有旋转。然而,当我说,让 iPad 在 View Controller 1 上以横向显示并按下按钮以显示 View Controller 2 时,问题就出现了,View Controller 2 出现得很好,但处于纵向模式。如果我处于 View Controller 2 的横向模式并转到 View Controller 1,也会发生同样的情况。如果我处于纵向模式,两个视图的一切都很好。
我怎样才能做到这一点,当我切换视图时,视图知道设备的方向并相应地旋转?
谢谢!
【问题讨论】:
标签: ipad ios5 rotation storyboard