在做iPad旋轉(zhuǎn)功能的時(shí)候距贷,發(fā)現(xiàn)shouldAutorotate轩端、supportedInterfaceOrientations等方法不調(diào)用,強(qiáng)制旋轉(zhuǎn)的方法也失效烦感⊙采纾可能的情況如下:
1. 多層級(jí)視圖導(dǎo)致的攔截情況,可參考:https://blog.csdn.net/zhaotao0617/article/details/51131038
2. 不需要全部方向都支持的情況手趣。項(xiàng)目里關(guān)于支持的方向的設(shè)置晌该,即Supported interface orientations。一共有三個(gè)key绿渣,即Supported interface orientations朝群,即Supported interface orientations (iPhone),即Supported interface orientations (iPad)中符。第一個(gè)是總體的默認(rèn)設(shè)置(也是General里面的Device Orientaion)姜胖,后面兩個(gè)是針對iPhone或iPad單獨(dú)的設(shè)置,若未設(shè)置則會(huì)按照默認(rèn)設(shè)置執(zhí)行淀散。這里的設(shè)置會(huì)優(yōu)先于回調(diào)的返回值右莱。
iPad支持的四個(gè)方向不全部勾選蚜锨,即Supported interface orientations (iPad) / Supported interface orientations最多設(shè)置三個(gè)。可能是因?yàn)閕Pad上supportedInterfaceOrientations默認(rèn)也是四個(gè)方向都支持慢蜓,所以設(shè)置了四個(gè)的話也就沒必要再回調(diào)了亚再。但是不論回調(diào)返回什么值,都無法旋轉(zhuǎn)到未設(shè)置的那個(gè)方向胀瞪。
3. 部分頁面需要全部方向支持针余,部分頁面要指定方向。此時(shí)需要勾選General中的Requires full screen凄诞,并且Supported interface orientations (iPad) / Supported interface orientations所有的方向都要設(shè)置。這樣shouldAutorotate忍级、supportedInterfaceOrientations等方法就會(huì)回調(diào)帆谍,強(qiáng)制旋轉(zhuǎn)的方法也會(huì)生效。但是APP就無法支持slipView了轴咱,要支持slipView就必須讓所有頁面都適配橫豎屏汛蝙。
后面內(nèi)容是來自官方的回復(fù)(TSI):If your app must support split view you will need to support all orientations and potential window sizes. As a general concept you can think a split screen app as an app that cannot require full screen and a full screen app as one that cannot support split views.?