以横向方式显示 Game Center 模态视图
我正在仅横向使用 cocos2d 引擎,没有自动旋转。
我想显示标准 GC 成就模式视图。 它从屏幕底部正常显示(在横向握住设备时),但它在屏幕右侧消失(如纵向模态视图)。它似乎正在改变关闭动画的方向,但在此之前视图没有旋转。它只是向右滑动。
另外,我在控制台中收到警告:
Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x41b9a0>.
这就是我显示此控制器的方式:
-(void)showAchievements:(id) sender {
utilityController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
[[[CCDirector sharedDirector] openGLView] addSubview:utilityController.view];
GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init];
if (achievements != nil)
{
achievements.achievementDelegate = self;
[utilityController presentModalViewController: achievements animated: YES];
}
[achievements release];
}
- (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController
{
[utilityController dismissModalViewControllerAnimated:YES];
[utilityController release];
}
在 gameConfig.h 中,我有以下配置:
#define GAME_AUTOROTATION kGameAutorotationNone
尝试将其更改为 kGameAutorotationCCDirector
- 同样的事情。 kGameAutorotationUIViewController
- uiview 在屏幕上跳跃。
请不要建议使用 CGAffineTransformMakeRotation
旋转 UIView - 这只是一个 hack...
I am using cocos2d engine in landscape-only orientation with no autorotation.
I want to display standart GC achievements modal view.
It's showing up normally, from bottom of screen (while holding device in landscape), but it is dismissing to the right side of the screen (like portrait modal views). It's seems to be changing orientation for dismiss animation, but view is not rotating before this. It's just sliding to the right.
Also I get a warning in console:
Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x41b9a0>.
That's how I showing this controller:
-(void)showAchievements:(id) sender {
utilityController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
[[[CCDirector sharedDirector] openGLView] addSubview:utilityController.view];
GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init];
if (achievements != nil)
{
achievements.achievementDelegate = self;
[utilityController presentModalViewController: achievements animated: YES];
}
[achievements release];
}
- (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController
{
[utilityController dismissModalViewControllerAnimated:YES];
[utilityController release];
}
In gameConfig.h I have following configuration:
#define GAME_AUTOROTATION kGameAutorotationNone
Tried to change this to kGameAutorotationCCDirector
- same thing. kGameAutorotationUIViewController
- uiviews are jumping all over the screen.
Please do not suggest rotating UIView with CGAffineTransformMakeRotation
- it's just a hack...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 Kobold2D 我用 类别GKMatchmakerViewController。您可以为其他 Game Center 视图控制器创建相同的类别。
这将强制 GC 视图使用当前设备方向:
For Kobold2D I solved this for all orientations with a category for the GKMatchmakerViewController. You can make the same category for the other Game Center view controllers.
This will force the GC views to use the current device orientation:
这是我在 Stackoverflow 上的第一个回答,所以如果任何格式可能不起作用,请原谅我。
无论如何,继续看代码。这个解决方案对我来说适用于成就视图控制器。任何其他 GK-Viewcontroller 都可以相应地工作...
This is my first ever answer on Stackoverflow, so please forgive me if any formatting may not work.
Anyway, on to the code. This solution works for me, for the Achievements-Viewcontroller. Any other GK-Viewcontroller may work accordingly...
尝试
在呈现 ViewController 之前调用
Try to call
Before presenting the ViewController