2013-05-04 108 views
2

我將Everyplay與我的Cocos2d Game.My遊戲整合,只支持橫向導向。 在iPad上一切順利。 但是當我在iPhone(iOS6)上測試時,當我打電話給「[[Everyplay sharedInstance] showEveryplay]」時,它會拋出異常:「 原因:'支持的方向與應用程序沒有共同的方向,並且shouldAutorotate返回YES'Everyplay是否支持iOS6中的橫向?

我知道方位機制iOS6.So改變了我加入這個方法:

-(BOOL)shouldAutorotate{ 
    return YES; 
} 
-(NSUInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskLandscape; 
} 
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ 
     return UIInterfaceOrientationMaskAllButUpsideDown; 
} 

然後「[Everyplay sharedInstance] showEveryplay]」的作品無一例外,但我的遊戲還支持縱向方向,我不希望至。

如果我只想支持我的遊戲中的橫向,但是讓[「[Everyplay sharedInstance] showEveryplay]」毫無例外地工作,我該怎麼辦?

回答

0

在iPhone上Everyplay webview始終處於肖像模式,但在iPad上,webview支持這兩種模式。錄製支持兩種模式,就像視頻播放器一樣。我們很可能在不久的將來更新iPhone分辨率的橫向模式,但在完成此任務之前需要重新設計。

2

你有兩個選擇如何解決這個問題。

選項1:

添加UISupportedInterfaceOrientations陣列到遊戲的Info.plist與項目UIInterfaceOrientationPortrait,UIInterfaceOrientationLandscapeLeft,UIInterfaceOrientationLandscapeRight和UIInterfaceOrientationPortraitUpsideDown。您可以通過從項目摘要頁面中檢查所有支持的界面方向或手動編輯info.plist文件,輕鬆地從xCode執行此操作。

選項2:

添加以下方法到應用程序的AppDelegate.m文件:

// IOS 6 

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 
    return UIInterfaceOrientationMaskAll; 
} 

在這兩種情況下,你還必須確保你已經添加了景觀僅取向處理代碼到您的遊戲的主要UIViewController。

// IOS 5 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation); 
} 

// IOS 6 

- (BOOL)shouldAutorotate { 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; 
} 
+0

選項2最適合我,謝謝 – user3610913 2014-06-25 09:57:25