Iphone 在景观中显示游戏中心模式视图
我正在使用cocos2d引擎,只面向横向,没有自动旋转 我想显示standart GC模式视图。 它在屏幕底部正常显示(在横向中握住设备),但在屏幕右侧显示(如纵向模式视图)。它似乎正在改变动画的方向,但在此之前视图并没有旋转。它只是向右滑动 我在控制台中还收到一条警告:Iphone 在景观中显示游戏中心模式视图,iphone,objective-c,cocos2d-iphone,modalviewcontroller,game-center,Iphone,Objective C,Cocos2d Iphone,Modalviewcontroller,Game Center,我正在使用cocos2d引擎,只面向横向,没有自动旋转 我想显示standart GC模式视图。 它在屏幕底部正常显示(在横向中握住设备),但在屏幕右侧显示(如纵向模式视图)。它似乎正在改变动画的方向,但在此之前视图并没有旋转。它只是向右滑动 我在控制台中还收到一条警告: Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x41b9a0>. 在gameConfig.h中,我有以下
Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x41b9a0>.
在gameConfig.h中,我有以下配置:
#define GAME_AUTOROTATION kGameAutorotationNone
尝试将此更改为kgameautrotationccdirector
-相同的操作<代码>kGameAutorotationUIViewController-uiviews在屏幕上跳跃
请不要建议使用CGAffineTransformMakeRotation旋转UIView,这只是一个黑客…,因为我用一个。您可以为其他游戏中心视图控制器创建相同的类别
这将强制GC视图使用当前设备方向:
@implementation GKMatchmakerViewController (OrientationFix)
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// [RootViewController option removed for clarity]
// all other autorotation types use the current device orientation
ccDeviceOrientation orientation = [CCDirector sharedDirector].deviceOrientation;
switch (interfaceOrientation)
{
case UIInterfaceOrientationPortrait:
return (orientation == kCCDeviceOrientationPortrait);
break;
case UIInterfaceOrientationPortraitUpsideDown:
return (orientation == kCCDeviceOrientationPortraitUpsideDown);
break;
case UIInterfaceOrientationLandscapeLeft:
return (orientation == kCCDeviceOrientationLandscapeRight);
break;
case UIInterfaceOrientationLandscapeRight:
return (orientation == kCCDeviceOrientationLandscapeLeft);
break;
default:
break;
}
return NO;
}
@end
这是我第一次回答Stackoverflow问题,所以如果任何格式都不起作用,请原谅我 不管怎么说,继续讲代码。这个解决方案适用于我,适用于Viewcontroller。任何其他GK Viewcontroller都可以相应地工作
@implementation GKAchievementViewController (OrientationFix)
-(BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
@end
@interface GKLeaderboardViewController (OrientationFix)
@end
-(void)showAchievements
{
GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init];
if (achievements != nil)
{
achievements.achievementDelegate = self;
[self presentModalViewController: achievements animated: YES];
}
[achievements release];
}
- (void)achievementViewControllerDidFinish: (GKAchievementViewController *)viewController
{
AppDelegate *delegate = [UIApplication sharedApplication].delegate;
[delegate.viewController dismissModalViewControllerAnimated:YES];
}
试着打电话
self.modalPresentationStyle = UIModalPresentationCurrentContext;
在演示ViewController之前谢谢您的回答,但是这个方向修正对我来说不适用于GKAchieventViewController。启动时,此视图仍从底部向上滑动,取消后,此视图将显示在屏幕的右侧。作为提醒,此示例代码适用于GKMatchmakerViewController。您确定为GK AchieventViewController修改了它吗?是的,当然。。这一次让它这样工作。稍后将进行调查。
self.modalPresentationStyle = UIModalPresentationCurrentContext;