0

我需要像在标准 iPod.app 中那样实现我的 UIViewController 子类的行为:当设备从纵向旋转到横向时,UIViewController 的内容保持静止并在其上方添加新视图。

问题是,当设置

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

内容正在旋转

但是当设置

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return NO;
}

功能

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    NSLog(@"did rotate form interface orientation %d",fromInterfaceOrientation);
}

是较新的称为

那么,你知道如何在不旋转内容的情况下处理 UIViewController 内的设备旋转吗?

4

1 回答 1

3

实际上,您不希望您的 viewController 响应界面方向旋转。

相反,只观察 UIAccelerometer 通知更容易。然后对视图进行完全交换。

您可以在 SO 上看到执行此操作的代码:

旋转 iPhone,并实例化一个新的 UIViewController?

UIDevice 方向

于 2009-06-27T20:41:21.263 回答