3 回答

TA貢獻(xiàn)1942條經(jīng)驗(yàn) 獲得超3個(gè)贊
這是我的“五美分”,已在iOS7和ARC上進(jìn)行了測(cè)試
[[UIDevice currentDevice] setValue:
[NSNumber numberWithInteger: UIInterfaceOrientationPortrait]
forKey:@"orientation"];
這不會(huì)像performSelector那樣生成“泄漏”警告。
UIAlertView-使用此代碼,當(dāng)您在視圖中打開UIAlertView時(shí)(會(huì)/已)出現(xiàn)時(shí),您會(huì)注意到,除了該視圖以外的所有視圖都是縱向的(蘋果,真的嗎?)我無法強(qiáng)制視圖重新定向,但是發(fā)現(xiàn)您在打開UIAlertView之前稍加延遲,然后視圖就有時(shí)間更改方向。
請(qǐng)注意,我將從2014年12月9日開始發(fā)布我的應(yīng)用程序周,如果發(fā)布會(huì)通過或失敗,我將對(duì)其進(jìn)行更新。

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超3個(gè)贊
這不能回答如何更改設(shè)備方向,而是可以幫助您的其他信息。
iOS 6 UI界面方向-shouldAutorotateToInterfaceOrientation:不起作用
iOS 6不支持方法shouldAutorotateToInterfaceOrientation:不建議使用。以防萬一,如果你是一個(gè)新手,誰只是盯著可可工作,并想知道為什么你的視圖控制器在iOS 6中搞砸了完善的iOS 5中,只知道shouldAutorotateToInterfaceOrientation:不支持了。即使它在Xcode 4到4.3上都能很好地工作,在Xcode 4.5上也無法工作。
蘋果提供了一種新的方法來以更清潔的方式完成此任務(wù)。您可以改用supportedInterfaceOrientations。它返回視圖控制器支持的所有界面方向,以及界面方向值的掩碼。
UIInterfaceOrientationMask枚舉:
這些常量是用于指定視圖控制器支持的接口方向的掩碼位。
typedef enum {
UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),
UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),
UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),
UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),
UIInterfaceOrientationMaskLandscape =
(UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
UIInterfaceOrientationMaskAll =
(UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
UIInterfaceOrientationMaskAllButUpsideDown =
(UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
UIInterfaceOrientationMaskLandscapeRight),
} UIInterfaceOrientationMask;
使用shouldAutorotateToInterfaceOrientation:方法:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscapeRight(toInterfaceOrientation);
}
使用supportedInterfaceOrientations方法:
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscapeRight;
}
這些是UIViewController中有關(guān)iOS6中方向的添加方法
UIViewController preferredInterfaceOrientationForPresentation
UIViewController應(yīng)該自動(dòng)旋轉(zhuǎn)
UIViewController支持的InterfaceOrientations
向UIApplication添加了有關(guān)iOS6中方向的方法
UIApplication支持的InterfaceOrientationsForWindow:
UIInterfaceOrientationMask
- 3 回答
- 0 關(guān)注
- 522 瀏覽
添加回答
舉報(bào)