iPhone prevent rotation of keyboard to landscape

谁说我不能喝 提交于 2019-12-24 02:30:35

问题


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?

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.

thanks, Pat


回答1:


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

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;
}

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.


From this SO article



来源:https://stackoverflow.com/questions/1948145/iphone-prevent-rotation-of-keyboard-to-landscape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!