我如何使用旋转code中的的iOS模拟器? [英] How do I rotate the iOS simulator using code?

查看:201
本文介绍了我如何使用旋转code中的的iOS模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何旋转iPhone模拟器(6.0及以上)?我已经搜查,但没有发现任何这一点。

Does anyone know how to rotate the iOS Simulator (6.0 and above)? I've searched but have found nothing on this.

我想通过code(没有手动)要做到这一点,但如果它可以通过一个脚本来完成,那么就必须从code运行。可即使这样做?有些建议需要的。

I am trying to do this through code (not manually), but if it can be done through a script, then it has to be run from code. Can this even be done? Some advice needed.

推荐答案

添加一个条目支持的接口方向的测试目标(或其他目标是合适的),这样​​的:

Add an entry for Supported interface orientations to the Tests target (or whatever target is appropriate) like this:

只要仅条目景观的人,这将在风景模式下运行。

As long as the only entries are Landscape ones, it will run in Landscape mode.

编辑:的结果
如果我误解你关于测试的评论,你是不是运行单元测试,你可能不希望保留改变你的主要目标的方向。在这种情况下,你可以复制你的主要目标,使方向改变那里。


If I misunderstood your comment about tests and you aren't running unit tests, you probably don't want to keep changing the orientation of your main target. In that case, you could duplicate your main target and make the orientation change there.

编辑:的结果
有一个无证的方法来迫使code转动。虽然这会为测试工作,它可以让你的应用程序被拒绝,如果你在提交应用程序中使用它。


There is an undocumented method to force rotation in code. While this will work for tests, it could get your app rejected if you use it in a submitted app.

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight animated:YES];

就包括这一类,无论你需要使用这个方法。

Just include this category wherever you need to use this method.

@interface UIDevice (MethodsThatAppleWillHitMeWithTheBanStickForUsing)
    -(void)setOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated;
    -(void)setOrientation:(UIInterfaceOrientation)orientation;
@end

这篇关于我如何使用旋转code中的的iOS模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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