【发布时间】:2023-03-26 10:44:01
【问题描述】:
我在 UIWindow 中添加了两个视图控制器作为子视图。现在的问题是视图之一得到视图旋转调用,但第二个是没有得到视图改变方向的调用。 现在我的问题是我们如何为 UIWindow 中添加的两个不同视图控制器获取更改方向调用。
【问题讨论】:
标签: iphone objective-c ios uiresponder
我在 UIWindow 中添加了两个视图控制器作为子视图。现在的问题是视图之一得到视图旋转调用,但第二个是没有得到视图改变方向的调用。 现在我的问题是我们如何为 UIWindow 中添加的两个不同视图控制器获取更改方向调用。
【问题讨论】:
标签: iphone objective-c ios uiresponder
UIWindow 仅向其rootViewController 发送轮换消息。如果您希望其他视图控制器接收它们,您有两种选择:
rootViewController 将旋转消息发送到另一个视图控制器。【讨论】:
UIWindow 的子视图,则必须使用CGAffineTransform。 UIWindow 为您设置rootViewController.view 的变换。如果您将其他子视图添加到窗口,您必须自己设置它们的变换。
注册设备方向。
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
检查方法,
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {
}
【讨论】: