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

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

在iOS 6中未調用shouldAutorotateToInterfaceOrientation

在iOS 6中未調用shouldAutorotateToInterfaceOrientation

iOS
慕雪6442864 2019-10-15 15:16:47
我正在使用MGSplitViewController,并且正在shouldAutorotateToInterfaceOrientation控制旋轉時主視圖控制器的大小。在iOS 5上一切正常,但在iOS 6(模擬器和iPad)shouldAutorotateToInterfaceOrientation上從未調用過。這是我應該期望在iOS 6的最終版本中修復的錯誤,還是我不知道的錯誤已更改?
查看完整描述

2 回答

?
Smart貓小萌

TA貢獻1911條經驗 獲得超7個贊

好的,我可以在iOS6 iPad Simulator中使用它。好極了。這是我所做的:


我只是告訴你之前和之后,這應該是不言而喻的:


之前


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {


if (interfaceOrientation==UIInterfaceOrientationPortrait) {

 // do some sh!t


}


return YES;

}


- (BOOL)shouldAutorotate {


UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];


if (orientation==UIInterfaceOrientationPortrait) {

 // do some sh!t


}


return YES;

}

至于支持的方向,您可以在info.plist中這樣指定: 

或使用代碼:


-(NSUInteger)supportedInterfaceOrientations{

    return UIInterfaceOrientationMaskPortrait; // etc

}

編輯:再三考慮,如果您打算支持較低版本(iOS4.3 / 5 / 5.1)以及6.0,則只需包含兩種具有相同代碼內容的方法即可。為我工作(無論如何在SIM卡中)


查看完整回答
反對 回復 2019-10-15
?
qq_花開花謝_0

TA貢獻1835條經驗 獲得超7個贊

這是針對iOS 5和更早版本代碼的解決方案,它不涉及重復邏輯。只需將此代碼添加到您的視圖控制器中,它就會從您現有的shouldAutorotateToInterfaceOrientation方法中生成supportedInterfaceOrientations。


-(BOOL)shouldAutorotate{

    return YES;

}


-(NSInteger)supportedInterfaceOrientations{

NSInteger mask = 0;

if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeRight])

    mask |= UIInterfaceOrientationMaskLandscapeRight;

if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeLeft])

    mask |= UIInterfaceOrientationMaskLandscapeLeft;

if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortrait])

    mask |= UIInterfaceOrientationMaskPortrait;

if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortraitUpsideDown])

    mask |= UIInterfaceOrientationMaskPortraitUpsideDown;

return mask;

}


查看完整回答
反對 回復 2019-10-15
  • 2 回答
  • 0 關注
  • 725 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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