IOS - 如何强制视图为横向 [英] IOS - How to force the view to landscape

查看:27
本文介绍了IOS - 如何强制视图为横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想强制我的视图选择横向,就在我调用方法时.

I want to force my view to go for landscape, just when I call a method.

当我的方法运行时,我调用:

When my method runs I call:

[self shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)UIInterfaceOrientationLandscapeRight];

自转方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

问题是视图不会强制旋转.可以在模拟器上测试,还是只能在真机上运行?

The problem is that the view don't force the rotation. Is possible to test it on the simulator, or just works in real device?

推荐答案

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];

这篇关于IOS - 如何强制视图为横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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