【发布时间】:2012-09-20 08:15:26
【问题描述】:
如果我在 iPad 上构建我的应用程序,它似乎处于纵向模式,并且设备方向更改不会影响它。我知道现在还很早,但这很重要,因为我必须尽快完成应用程序。有人知道解决这个问题吗?
【问题讨论】:
标签: iphone ipad cocos2d-iphone orientation xcode4.5
如果我在 iPad 上构建我的应用程序,它似乎处于纵向模式,并且设备方向更改不会影响它。我知道现在还很早,但这很重要,因为我必须尽快完成应用程序。有人知道解决这个问题吗?
【问题讨论】:
标签: iphone ipad cocos2d-iphone orientation xcode4.5
好的,我在cocos2d forums 中遇到了一个修复方法
只需进入您的应用委托并更改这行代码:
// set the Navigation Controller as the root view controller
[window addSubview:viewController.view];
对此:
// set the Navigation Controller as the root view controller
[window setRootViewController: viewController];
【讨论】:
我认为您使用的是 cocos2d-v-1.0 版本。尝试新的 cocos2d 版本(cocos2d-v2.0),它会正常工作。
在 appdelegate.m 中
navController_ = [[UINavigationController alloc] initWithRootViewController:director_];
navController_.navigationBarHidden = YES;
[window_ setRootViewController:navController_];
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
在我的情况下,它工作正常,一旦检查。
【讨论】:
我尝试了@user1066899 方法,但没有成功。但是,我确实通过完全删除“shouldAutorotateToInterfaceOrientation”委托方法并在“摘要”下的构建设置中设置支持的横向方向来解决此问题。
【讨论】:
摘要未设置 plist。通常您可以在摘要中进行设置。
这应该可以让您在两个设备的目标摘要中设置方向:
点击蓝色图标
点击双铅笔和尺子图标
点击摘要
单击适用的支持的接口方向
但是这个界面有问题。设置未从此屏幕正确更改。
您必须手动设置 plist。
在项目导航器的 Supporting Files 中找到 NAME-Info.plist
初始界面方向
设置支持的界面方向 (iPad)
设置支持的界面方向 (iPhone)
【讨论】: