iOS 8自动旋转将图像从屏幕上旋转 [英] iOS 8 autorotate rotates images off the screen
问题描述
所以我最近听到客户说的一个奇怪的问题。当他们试图旋转屏幕时,屏幕会变黑。这似乎是一个iOS 8的事情,因为我最新的版本只是添加iOS 8的混合。
So I recently heard word from my customers about a strange issue. The screen will go black on them when they try to rotate their screen. This appears to be an iOS 8 thing only since my latest release was just to add iOS 8 to the mix.
从我的viewcontroller:
From my viewcontroller:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
//
// There are 2 ways to support auto-rotation:
// - The OpenGL / cocos2d way
// - Faster, but doesn't rotate the UIKit objects
// - The ViewController way
// - A bit slower, but the UiKit objects are placed in the right place
//
#if GAME_AUTOROTATION==kGameAutorotationNone
//
// EAGLView won't be autorotated.
// Since this method should return YES in at least 1 orientation,
// we return YES only in the Portrait orientation
//
return ( interfaceOrientation == UIInterfaceOrientationPortrait );
#elif GAME_AUTOROTATION==kGameAutorotationCCDirector
//
// EAGLView will be rotated by cocos2d
//
// Sample: Autorotate only in landscape mode
//
if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ) {
[[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight];
} else if( interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeLeft];
}
// Since this method should return YES in at least 1 orientation,
// we return YES only in the Portrait orientation
return ( interfaceOrientation == UIInterfaceOrientationPortrait );
#elif GAME_AUTOROTATION == kGameAutorotationUIViewController
//
// EAGLView will be rotated by the UIViewController
//
// Sample: Autorotate only in landscpe mode
//
// return YES for the supported orientations
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
#else
#error Unknown value in GAME_AUTOROTATION
#endif // GAME_AUTOROTATION
// Shold not happen
return NO;
}
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskLandscape;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
我能够在我的设备上再现它, ..
I was able to reproduce it on my device as well as the simulator....
风景左
Portrait
横向右
Landscape Left Portrait Landscape Right
从我可以看出, iPad测试,是图像实际上自己旋转屏幕。我目前允许所有4个方向,即使游戏是在风景,因为我使用游戏中心和至少一些旧的iOS需要肖像登录。我使用的是一个相当老版本的cocos2d(v1.1.0-beta2b),但我从来没有经历过这样的事情。我可能只是改变支持的方向,并关闭自动旋转,但我想修复它。这是怎么回事?
From what I can tell based on this a similar iPad test, is that the image actually rotates itself off the screen. I currently allow all 4 orientations even though the game is in landscape because I'm using game center and at least some older iOSes required portrait log ins. I'm using a rather old version of cocos2d (v1.1.0-beta2b), but I've never experienced anything like this before. I can probably just change the supported orientations and turn off auto rotate, but I would like to fix it. What's going on here?
推荐答案
我有问题cocos1.0以及当我编译ios8。在我的代码中,我发现我有一个UIViewController用作根视图控制器(它的孩子是在Coca2D使用的EAGLView)。
I've got the issue with cocos1.0 as well when I compile for ios8. In my code I found that I did have a UIViewController that is used as the root view controller (its child is in the EAGLView used by Cocos2D).
是从我的UIViewController注释以下方法
The fix I found is to comment the following method from my UIViewController
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
我对ios8和ios7做了快速测试,它的工作
I've done quick test on ios8 and ios7, and it works
这篇关于iOS 8自动旋转将图像从屏幕上旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!