如何在 UINavigationController 中的单个视图上强制使用特定的 UIInterfaceOrientation? [英] How do I force a specific UIInterfaceOrientation on an individual view in a UINavigationController?

查看:14
本文介绍了如何在 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆