我想允許應轉動的基礎上,目標方位目標取向shouldAutorotate
[[UIDevice currentDevice] orientation]
然而,在shouldRotate使用時,上面的代碼,保存當前(舊)方向,而不是目標方位
- (BOOL) shouldAutorotate {
return YES;
}
我想允許應轉動的基礎上,目標方位目標取向shouldAutorotate
[[UIDevice currentDevice] orientation]
然而,在shouldRotate使用時,上面的代碼,保存當前(舊)方向,而不是目標方位
- (BOOL) shouldAutorotate {
return YES;
}
好吧,我想通了。在shouldAutorotate返回YES總是然後做到這一點:
- (NSUInteger)supportedInterfaceOrientations
{
if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft) {
// Allow if you can
} else if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
// Allow if you can
}
// so on
}
除了是返回
-(BOOL)shouldAutorotate
{
return YES;
}
你必須實現
個- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
不同的掩碼可用是:
UIInterfaceOrientationMaskPortrait
UIInterfaceOrientationMaskLandscapeLeft
UIInterfaceOrientationMaskLandscapeRight
UIInterfaceOrientationMaskPortraitUpsideDown
UIInterfaceOrientationMaskLandscape
UIInterfaceOrientationMaskAll
UIInterfaceOrientationMaskAllButUpsideDown
您還可以看到:
是的,我知道,但那不是一個ansewer我的問題:(如何檢測的目標方向 –
的OP詢問如何檢測的目標方向,我們已經知道我們應該回到YES,如果我們想自動旋轉。 – strange
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
此方法應該爲你做的伎倆。 toInterfaceOrientation保持目標方向。
你可以請升級答案......那些降低了我的其他答案的人...... – iSaalis
您是否找到任何解決方案? – strange