如何在 UITabBarController->UINavigationController 中的 ViewController 上获取旋转事件?
我想每当用户将 iOS 设备从纵向旋转到横向时显示全屏横向视图,其中纵向视图是 TabBar 和 NavigationController 内的视图。
但是, willRotateToInterfaceOrientation:duration: 永远不会被调用。我还测试了将 ViewController 添加为 UIDeviceOrientationDidChangeNotification 事件的观察者,但也以未定义的方向调用此通知。
完成给定任务的最佳和最简单的方法是什么?
I wanna show a full-screen Landscape view whenever the user rotates the iOS device from portrait to landscape, where the portrait view is a view within a TabBar and NavigationController.
However, willRotateToInterfaceOrientation:duration: is never called. I tested also to add the ViewController as Observer of UIDeviceOrientationDidChangeNotification events, but this notification is called also with undefined orientation.
What would be the best and easiest way for the given task?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
还有
UIApplicationWillChangeStatusBarOrientationNotification
和UIApplicationDidChangeStatusBarOrientationNotification
通知。userInfo
字典包含一个 NSNumber 对象,该对象封装了UIInterfaceOrientation
值。使用 UIApplicationStatusBarOrientationUserInfoKey 访问此值There are also
UIApplicationWillChangeStatusBarOrientationNotification
andUIApplicationDidChangeStatusBarOrientationNotification
notifications.The
userInfo
dictionary contains an NSNumber object that encapsulates aUIInterfaceOrientation
value. UseUIApplicationStatusBarOrientationUserInfoKey
to access this value