iPhone防止键盘旋转到横向 [英] iPhone prevent rotation of keyboard to landscape

查看:95
本文介绍了iPhone防止键盘旋转到横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在MPMoviePlayerController上放置了一些控件,并且打算将其用于纵向模式,只需使用垂直拍摄的视频即可.我唯一的问题是,对于文本输入,键盘会横向显示.

So, I'm putting some controls over an MPMoviePlayerController and I'm intending this to be used in portrait mode, simply by using video that is shot vertically. My only problem is that for text entry the keyboard comes up in landscape.

现在,我意识到可以通过一种未公开的方式来设置播放器的方向,但是我宁愿不尝试这种方式并在应用商店中被拒绝. (仅供参考):

Now, I realize that there is an undocumented way to set the orientation of the player, but I'd rather not try this and get rejected at the app store. (FYI this is it):

[moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO]; // not legal?

我尝试在视图控制器中覆盖autorotate方法:

I've tried overriding the autorotate method in my view controller:

   -(BOOL)shouldAutorotateToInterfaceOrientation:   (UIInterfaceOrientation)interfaceOrientation { return NO; }

但是一旦电影播放器​​开始播放,它就会接管并且不尊重它.

but it once the movie player starts playing it takes over and doesn't respect this.

我只是想知道,即使电影播放器​​想要使系统横向运行,是否有人还有其他想法可以合法地使键盘保持竖向状态.

I'm just wondering if anyone has any other ideas on a legal way to keep the keyboard in portrait even while the movie player wants to take the system to landscape.

谢谢, 帕特

推荐答案

旋转iPhone时,将向顶层"视图发送通知,该视图负责布置其子视图.

When the iPhone is rotated, the "top level" view is sent the notification, and that view is responsible for laying out its subviews.

如果UIWebView是顶级视图,它将自动旋转.但是,如果将UIWebView放在另一个视图中,并让该容器"视图的视图控制器实现如下的shouldAutorateToInterfaceOrientation方法:

If your UIWebView is the top level view, it will autorotate itself. However, if you put the UIWebView inside of another view, and have the view controller for that "container" view implement the shouldAutorateToInterfaceOrientation method like this:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return NO;
}

这可能会阻止UIWebView知道界面已旋转.请注意,我实际上没有尝试过,但是应该可以.

That would probably prevent the UIWebView from knowing the interface was rotated. Note that I haven't actually tried this, but it should would work.

SO文章

这篇关于iPhone防止键盘旋转到横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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