我有一部iPhone 4S(运行iOS 5.1)& iPhone 5(运行iOS 6.1)。我注意到当我尝试打开cocos2D
游戏时,在运行5.1的iPhone 4S上,游戏能够在横向模式下打开完美。
但是,当我尝试在运行6.1的iPhone 5上打开相同的cocos2D
游戏时,游戏将以纵向模式打开。
有没有办法可以在运行iOS 6.1的iPhone 5中将cocos2D
游戏旋转到横向模式。
一些额外的说明:
我也尝试过不同的方法,例如iOS 6,例如:
-(NSUInteger)supportedInterfaceOrientations
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
-(BOOL)shouldAutorotate
但是当我尝试这些方法时,它给了我不同的结果。
理想情况下,我希望将应用程序锁定在纵向模式,将游戏锁定为横向模式。
所以,我想知道是否可以让一个应用程序在纵向模式下保持锁定状态,并且游戏在横向模式下锁定(适用于iOS 5和iOS 6)?
这是我正在处理的示例项目的链接:
答案 0 :(得分:2)
我只是将Xcode中的方向模式(目标上的“摘要”标签)设置为左右横向。然后对于每个UIViewController我添加了这个:
// Autorotation iOS5 + iOS6
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
答案 1 :(得分:1)
我在cocos2d游戏(iOS 6.1)中为横向做的事情:
//This is in the AppDelegate.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
//change to 'return UIInterfaceOrientationIsPortrait(interfaceOrientation);' for portrait
}