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

查看:86
本文介绍了如何在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?

推荐答案

您可以尝试强制设备旋转到必要的方向 - 但您需要手动处理它(除了重写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天全站免登陆