2012-11-13 35 views
1

我在iPhone上開發一個簡單的遊戲。整個遊戲處於橫向模式,但記分牌頁面僅支持縱向模式。我在這裏檢查了問題,我只找到了轉向縱向模式,但我需要相反的答案。任何人都可以幫我嗎?iphone如何改變風景到人像?

+0

這裏是同一個線程http://stackoverflow.com/questions/ 12577879/shouldautorotatetointerfaceorientation-is-not-working-in-ios-6/12581799#12581799 – Kamarshad

回答

0

這很簡單。首先,確保目標摘要中支持縱向和橫向取向。然後:

在景觀ViewControllers,補充一點:

-(NSUInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

而在縱向視圖控制器,補充一點:

-(NSUInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskPortrait; 
} 
+0

非常感謝你! – Toygirl

0

我在AppDelegate中使用了這兩個調用。只獲取橫向比賽中心(比分板)。

// Supported orientations: Landscape. Customize it for your own needs 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
} 



#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0 
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window 
{ 
    return UIInterfaceOrientationMaskAllButUpsideDown; //Getting error here? then update ur xcode to 4.5+ 
} 
#endif 

Xcode設置:標記橫向。 enter image description here

+0

shouldAutorotateToInterfaceOrientation自iOS 6起棄用。 – WolfLink

+0

@WolfLink,yes,supportedInterfaceOrientationsForWindow用於我的代碼中的ios6..its working great :) anyway謝謝 – Guru

+0

也謝謝你:) – Toygirl