Xcode设置应用支持的方向

2017-08-26  本文已影响42人  粑粑又被注册了嘛

Xcode 默认支持的方向有:Portrait、Landscape Left、Landscape Right,默认Upside Down 方向不支持,这是因为IPhone 在使用过程中,接到来电,很容易就会把听筒和话筒位置搞反。

打开Xcode,在 General -》Deployment Info 中,可以看到,默认只勾选了三个方向,

此时,我们把 Upside Down 也勾选中,会发现 IPad 已默认支持四个方向,但在IPhone中,还是默认只支持三个方向,此时,需要在控制器中,显示声明一下来支持Upside Down方向。具体代码如下:

- (NSUInteger)supportedInterfaceOrientations

{

returnUIInterfaceOrientationMaskAll;

}

这样,IPhone 和 IPad 一样,四个方向都支持了。

总结:想要App支持某个方向,需要两个设置:

一:Deployment Info 中,勾选 Device Orientation ;

二:在控制器中,重写 supportedInterfaceOrientations 方法。(如不重写,IPad 默认是UIInterfaceorientationMaskAll , IPhone 默认是 UIInterfaceOrientationMaskAllButUpsideDown )。

上一篇 下一篇

猜你喜欢

热点阅读