Iphone 如何将视图从纵向模式更改为横向模式?
我想在纵向模式下更改第一个视图,在横向模式下更改第二个视图,我使用的是Iphone 如何将视图从纵向模式更改为横向模式?,iphone,cocos2d-iphone,Iphone,Cocos2d Iphone,我想在纵向模式下更改第一个视图,在横向模式下更改第二个视图,我使用的是gameconfig.h文件 代码是: // // GameConfig.h // Cocos2DSimpleGame // // Created by Ray Wenderlich on 11/21/10. // Copyright Ray Wenderlich 2010. All rights reserved. // #ifndef __GAME_CONFIG_H #define __GAME_CONFIG_H
gameconfig.h
文件
代码是:
//
// GameConfig.h
// Cocos2DSimpleGame
//
// Created by Ray Wenderlich on 11/21/10.
// Copyright Ray Wenderlich 2010. All rights reserved.
//
#ifndef __GAME_CONFIG_H
#define __GAME_CONFIG_H
//
// Supported Autorotations:
// None,
// UIViewController,
// CCDirector
//
#define kGameAutorotationNone 0
#define kGameAutorotationCCDirector 1
#define kGameAutorotationUIViewController 2 //2
//
// Define here the type of autorotation that you want for your game
//
#define GAME_AUTOROTATION kGameAutorotationUIViewController
#endif // __GAME_CONFIG_H
and in my appDelegate file is:
#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
#else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
//[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
// [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
#endif
在第一个视图中,我想以纵向模式显示菜单,并且当我单击新游戏时,游戏将以横向模式显示。我还使用了
shouldAutoInterfaceOrientation
,但我还没有找到解决方案。如果要更改方向,请调用此函数:
[[CCDirector sharedDirector]setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
我可以借助#define kgameautrotationuiviewcontroller 2 view轻松解决我的问题,每当我将其值更改为1时,方向为纵向模式,当我更改其值时,视图将以横向模式显示,为给我提供建议,请格式化您的代码。像这样读真的很难。。。