当应用程序的其余部分处于纵向模式时,强制界面方向在viewController上显示 [英] Force Interface orientation Landscape on a viewController when the rest of the application is in portrait mode
问题描述
晚上好!
我正在开发一个以Portait为导向的应用程序,如果有一种方法可以让我将一个视图的方向更改为剩余的空间而不会弄乱应用程序的剩余部分,我就会徘徊。
Good evening all! I am developing an application in Portait orientation and i was wander if there is a way for me to change the orientation of only one view to landspace left without messing with the rest of the app.
我试过返回
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
//return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
但没有运气......在IB中,View控制器的方向是设置为横向,但是当我运行应用程序时,它仍然以纵向模式显示...还尝试设置
but with no luck... In IB the orientation for the View controller is set to landscape but when i run the app, it keeps appearing in portrait mode... Also tried setting the
[[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
没有运气...
任何帮助将不胜感激。
谢谢。
推荐答案
唯一对我有用的是使用
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
并使用 presentModalViewController 即可。
这会强制视图保持格局。
in my ViewController and presenting it with presentModalViewController. This forces the View to stay in landscape.
这篇关于当应用程序的其余部分处于纵向模式时,强制界面方向在viewController上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!