How do I force a specific UIInterfaceOrientation on an individual view in a UINavigationController?(如何在 UINavigationController 中的单个视图上强制使用特定的 UIInterfaceOrientation?)
问题描述
好的,情况如下:
我有一个应用程序,我只希望 UINavigationController 中的一个特定视图具有横向方向.这个视图是一个 UIImageView,我在上面捕获了一个签名(那部分效果很棒).所以,像这样:
I have an app in which I only want ONE specific view in a UINavigationController to have a landscape orientation. This view is a UIImageView that I'm capturing a signature on (THAT part works awesome). So, like this:
previous view --> signature view --> next view
(portrait) (landscape) (portrait)
我似乎找不到在该签名屏幕上强制设备方向为横向的好方法.在签名视图上设置纵向是没有意义的,因为在该屏幕宽度上确实没有足够的空间进行登录.
I can't seem to find a good way to force the device orientation to landscape on that signature screen. It'll never make sense to have a portrait orientation on the signature view because there's really not adequate room for signing in that screen width.
那么,关于如何实现这一点有什么好主意吗?我考虑过可能会以模态方式进行签名视图,从而脱离导航控制器.想法?
So, any bright ideas on how to accomplish this? I've considered possibly doing the signature view modally, thus breaking out of the navigation controller. Thoughts?
推荐答案
您可以尝试强制 Device 旋转到必要的方向 - 但您需要手动处理它(除了重写 UIViewController 方向处理方法).
You can try to force Device to rotate to necessary orientation - but you need to handle it manually (in addition to overriding UIViewController orientation handling methods).
要旋转设备,您可以使用以下方法:
To rotate device you can use next methods:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
但它可能不适用于所有情况......
But in it may not work in all situations...
也可用无证方法:
[[UIDevice currentDevice] performSelector:NSSelectorFromString(@"setOrientation:")
withObject:(__bridge id)((void*)UIInterfaceOrientationLandscapeLeft)];
这篇关于如何在 UINavigationController 中的单个视图上强制使用特定的 UIInterfaceOrientation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 UINavigationController 中的单个视图上强制使用特定的 UIInterfaceOrientation?


- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- URL编码Swift iOS 2022-01-01
- UITextView 内容插图 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01