如何将纵向视图更改为横向模式?

问题描述:

我想在纵向模式下更改第一个视图,并且第二个视图进入横向模式,我正在使用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,但我还没有找到解决方案。

+0

请格式化您的代码。像这样阅读真的很难...... – 2011-02-14 16:21:03

每当我它的值改为1取向我很容易地解决我的问题的#define kGameAutorotationUIViewController 2视图的帮助是肖像模式和时我改变了它的价值观点将显示在横向模式,thnx给我的建议

当你想改变方向,调用这个函数:

[[CCDirector sharedDirector]setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];