我是cocos2d游戏开发的新手。在这里,我的游戏是在纵向模式下开发的。我只是想转换一下横向模式。并告诉我使用哪种方法来代替shouldAutorotateToInterfaceOrientation方法,因为iOS 6中不提供此方法?
我的整个游戏从一开始就是人像模式。
提前谢谢你。
发布于 2013-05-22 14:31:08
我不确定这会不会解决你的问题,但正如你提到的如何在OS6中处理方向,我想给你我在iOS 6和iO5等中用来处理设备方向的代码。
下面是代码片段,您可以在其中决定要在应用程序中使用的方向支持
处理iOS 5和iOS 6中的屏幕方向
//For up-to iOS 5.0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported all orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
//For iOS 6.0
-(NSInteger)supportedInterfaceOrientations
{
//Supporting only portrait orientation.
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotate
{
return NO;
}Reference
希望这能对你有所帮助!
发布于 2013-05-22 14:13:20
您将在appdelegate.mm文件中找到以下代码
#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
#else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];将其更改为。
#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
#else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];让我知道它是否正常工作!
发布于 2013-05-22 13:53:17
转到目标并设置支持的接口方向。
https://stackoverflow.com/questions/16684377
复制相似问题