亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

支持的方向與應用程序沒有通用的方向,并且應該Autorotate返回YES'

支持的方向與應用程序沒有通用的方向,并且應該Autorotate返回YES'

iOS
30秒到達戰場 2019-10-17 14:18:24
我的應用程序(iPad; iOS 6)是僅橫向應用程序,但是當我嘗試使用UIPopoverController顯示照片庫時,會引發此錯誤: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES.我嘗試過更改很多代碼,但是沒有運氣。
查看完整描述

3 回答

?
暮色呼如

TA貢獻1853條經驗 獲得超9個贊

在IOS6中,您在三個地方都支持界面方向:


.plist(或“目標摘要”屏幕)

您的UIApplicationDelegate

正在顯示的UIViewController

如果遇到此錯誤,則很可能是因為您在UIPopover中加載的視圖僅支持縱向模式。這可能是由Game Center,iAd或您自己的視圖引起的。


如果是您自己的視圖,則可以通過重寫UIViewController上的supportedInterfaceOrientations來修復它:


- (NSUInteger) supportedInterfaceOrientations

{

     //Because your app is only landscape, your view controller for the view in your

     // popover needs to support only landscape

     return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;

}

如果不是您自己的視圖(例如iPhone上的GameCenter),則需要確保.plist支持縱向模式。您還需要確保UIApplicationDelegate支持以縱向模式顯示的視圖。您可以通過編輯.plist,然后在UIApplicationDelegate上覆蓋supportedInterfaceOrientation來做到這一點:


- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window

{

    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;

}


查看完整回答
反對 回復 2019-10-17
?
翻閱古今

TA貢獻1780條經驗 獲得超5個贊

在另一種情況下,可能會出現此錯誤消息。我花了好幾個小時才找到問題。閱讀幾次后,此線程非常有幫助。


如果將主視圖控制器旋轉為橫向,并且您調用一個應以縱向顯示的自定義子視圖控制器,則在代碼如下所示時可能會發生此錯誤消息:


- (NSUInteger)supportedInterfaceOrientations {


    return UIInterfaceOrientationPortrait;

}

這里的陷阱是xcode的intellisense建議“ UIInterfaceOrientationPortrait”,我對此并不在意。乍一看,這似乎是正確的。


右邊的面具叫


UIInterfaceOrientationMaskPortrait

請注意小前綴“ Mask”,否則您的子視圖將最終出現異常和上面提到的錯誤消息。


新的枚舉進行了位移。舊的枚舉返回無效值!


(在UIApplication.h中,您可以看到新的聲明:UIInterfaceOrientationMaskPortrait =(1 << UIInterfaceOrientationPortrait))


解決方案是:


- (BOOL)shouldAutorotate {


    return YES;

}


- (NSUInteger)supportedInterfaceOrientations {


    // ATTENTION! Only return orientation MASK values

    // return UIInterfaceOrientationPortrait;


    return UIInterfaceOrientationMaskPortrait;

快速使用


override func shouldAutorotate() -> Bool {


    return true

}


override func supportedInterfaceOrientations() -> Int {


    return Int(UIInterfaceOrientationMask.Portrait.rawValue)

}


查看完整回答
反對 回復 2019-10-17
  • 3 回答
  • 0 關注
  • 1914 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號