天天看點

cocos2d 設定螢幕預設方向

在cocos2d建立的新工程運作結果螢幕都是橫向,控制代碼

這段代碼控制的是螢幕視圖預設橫向顯示;

還有一個需要差別的是硬體裝置方向(灰黑色背景表示被選擇,所支援方向)

當你旋轉裝置方向時候,發現當螢幕豎着的時候,視圖裡面内容并未調整,标簽HelloWord并未橫着放

如果想讓運作時候預設豎屏,修改代碼傳回值(或者 return YES;也行)

裝置支援方向前兩個必選,後面兩個看需要,需要的話也可以選上;

 UIInterfaceOrientationIsPortrait和UIInterfaceOrientationIsLandscape在UIApplication.h檔案中宏定義

#define UIInterfaceOrientationIsPortrait(orientation)  ((orientation) == UIInterfaceOrientationPortrait || (orientation) == UIInterfaceOrientationPortraitUpsideDown)

#define UIInterfaceOrientationIsLandscape(orientation) ((orientation) == UIInterfaceOrientationLandscapeLeft || (orientation) == UIInterfaceOrientationLandscapeRight)

     本文轉自新風作浪 51CTO部落格,原文連結:http://blog.51cto.com/duxinfeng/1208775,如需轉載請自行聯系原作者

繼續閱讀