已经在AppDelegate.m中添加了以下代码,但仍然没有在纵向工作.
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
Run Code Online (Sandbox Code Playgroud)
这是Xcode摘要页面:

有解决方案.我们可以在setupCocos2dWithOptions中设置方向.
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self setupCocos2dWithOptions:@{
CCSetupShowDebugStats: @(YES),
CCSetupScreenOrientation: CCScreenOrientationPortrait,
}];
return YES;
}
Run Code Online (Sandbox Code Playgroud)