0

我在 UIWindow 中添加了两个视图控制器作为子视图。现在的问题是视图之一得到视图旋转调用,但第二个是没有得到视图改变方向的调用。现在我的问题是我们如何获得对 UIWindow 中添加的两个不同视图控制器的更改方向调用。

4

2 回答 2

1

UIWindow仅将轮换消息发送到其rootViewController. 如果您希望其他视图控制器接收它们,您有两种选择:

  1. 编写代码以使您rootViewController将旋转消息发送到其他视图控制器。
  2. 实现视图控制器包含。观看来自WWDC 2011的实现 UIViewController Containment视频,了解如何执行此操作。
于 2012-02-17T07:22:15.213 回答
0

注册设备方向。

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];

检查方法,

 if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) || 
        ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {


}
于 2012-02-17T08:04:10.093 回答