Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 当我从Landscape Left旋转到Landscape Right,从Landscape Right旋转到Landscape Left时,我的应用程序会显示黑色屏幕_Ios_Iphone_Cocos2d Iphone_Cocos2d X_Uiinterfaceorientation - Fatal编程技术网

Ios 当我从Landscape Left旋转到Landscape Right,从Landscape Right旋转到Landscape Left时,我的应用程序会显示黑色屏幕

Ios 当我从Landscape Left旋转到Landscape Right,从Landscape Right旋转到Landscape Left时,我的应用程序会显示黑色屏幕,ios,iphone,cocos2d-iphone,cocos2d-x,uiinterfaceorientation,Ios,Iphone,Cocos2d Iphone,Cocos2d X,Uiinterfaceorientation,嗨,我是iOS开发者的新手 当我将Landscape从左旋转到右时,我的应用程序出现问题。我的应用程序显示为黑屏 我使用这种方法进行旋转 -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ CGRect screenRect = [[UIScreen mainScreen] bounds];

嗨,我是iOS开发者的新手

当我将Landscape从左旋转到右时,我的应用程序出现问题。我的应用程序显示为黑屏

我使用这种方法进行旋转

 -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{

    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGRect rect = CGRectZero;


    if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)      
        rect = screenRect;

    else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
        rect.size = CGSizeMake( screenRect.size.height, screenRect.size.width );

    CCDirector *director = [CCDirector sharedDirector];
    EAGLView *glView = [director openGLView];
    float contentScaleFactor = [director contentScaleFactor];

    if( contentScaleFactor != 1 ) {
        rect.size.width *= contentScaleFactor;
        rect.size.height *= contentScaleFactor;
    }
    glView.frame = rect;
}

你为什么这么做?你的这个方法执行什么?当我旋转这个方法调用@Lionwhat当你的设备旋转或方向改变时你想要什么?但是什么呢?设备旋转时需要什么?此方法用于在设备旋转时执行某些任务。那么,当设备旋转时,您想执行什么操作?@lion是的,我想旋转设备。您为什么要这样做?你的这个方法执行什么?当我旋转这个方法调用@Lionwhat当你的设备旋转或方向改变时你想要什么?但是什么呢?设备旋转时需要什么?此方法用于在设备旋转时执行某些任务。那么,当设备处于旋转状态时,您想执行什么操作?@lion是的,我想旋转设备。