当我与cocos2d和cocosbuilder一起工作时,我遇到了景观旋转的问题。
我在我的协同构建器项目和xcode 支持的接口方向(iPhone Suported Orientations )上都有iPhone、景观和iPhone5 ,我只选择了景观。
在我的代理上。我有:
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}这应该很简单,但是我在这里很困难,而且不想在不使用cocosbuilder的情况下重新组装游戏。
发布于 2013-03-14 15:27:13
如果您支持最新版本的iOS,而这些版本现在主要使用,那么您应该使用这些方法来检查方向。
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
-(BOOL)shouldAutorotate {
return YES;
}shouldAutorotateToInterfaceOrientation在iOS6中是不推荐的,而不是使用这个方法,而是使用我提供的上述方法,并在那里阅读苹果提供的UIViewController文档,它清楚地说明了您可以使用哪些方法,以及用于什么目的。以下是您可能使用的一些方法
willRotateToInterfaceOrientation:duration:
willAnimateRotationToInterfaceOrientation:duration:
and didRotateFromInterfaceOrientation:https://stackoverflow.com/questions/15413287
复制相似问题