cocos2D默认的为横屏,但是要咋改?在网上找了一个多小时,很多都是只言片语的,不详细,一头雾水!后来终于找到了答案原来要改屏幕方向,不仅要改改代码就行!!!!!我趣~~~~~ “cocs2D-iPhone2.0 屏幕方向 ”要注意代码、ios版本、xcod的设定三点:
首先,xcode的设置
如果需要代码生效,请将 项目(左边蓝色图标那货)-》TARGETS-》Summary-》support interface orientations 中所有的屏幕方向点击设定无效,否则代码会失效。很重要的是这里ios6实测,就算这样设定后,在一些情况下屏幕方向设定还是有BUG。
代码、版本
2.0修改横竖屏在AppDelegate.m文件中有如下代码
<AppDelegate.m>iOS 6+设置使用
1 // Only valid for iOS 6+. NOT VALID for iOS 4 / 5. 2 -(NSUInteger)supportedInterfaceOrientations { 3 4 // iPhone only 5 if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) 6 return UIInterfaceOrientationMaskPortrait; //竖屏设置 7 //return UIInterfaceOrientationMaskLandscape; //横屏设置 8 9 // iPad only 10 return UIInterfaceOrientationMaskPortrait; //竖屏设置 11 //return UIInterfaceOrientationMaskLandscape; //横屏设置 12 }
<AppDelegate.m>iOS 4/5设置使用
1 // Only valid on iOS 4 / 5. NOT VALID for iOS 6. 2 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 3 { 4 // iPhone only 5 if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) 6 return UIInterfaceOrientationIsPortrait(interfaceOrientation); //竖屏设置 7 //return UIInterfaceOrientationIsLandscape(interfaceOrientation); //横屏设置 8 9 // iPad only 10 // iPhone only 11 //return UIInterfaceOrientationIsLandscape(interfaceOrientation); //横屏设置 12 return UIInterfaceOrientationIsPortrait(interfaceOrientation); //竖屏设置 13 }