我在我的游戏中使用 Facebook SDK 以便在 Facebook 上发布一些分数。我的代码使用的是 Cocos2D 框架,所以我不得不添加一些代码来启用 UIView。一切正常,除了视图以纵向显示,尽管我的笔尖属性指示横向,ShouldautoRotate 方法返回横向,并且应用程序方向也是横向。这是设置视图的代码:
// share to facebook methods
-(void)shareFacebookSelected
{
[[SimpleAudioEngine sharedEngine]stopBackgroundMusic];
[[CCDirector sharedDirector] pause];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
myViewController1 = [[HFViewController alloc] initWithNibName:@"HFViewController_iPhone" bundle:nil];
} else {
myViewController1 = [[HFViewController alloc] initWithNibName:@"HFViewController_iPad" bundle:nil];
}
UIWindow* window = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:window cache:YES];
[[[CCDirector sharedDirector]view] removeFromSuperview];
myViewController1.view.hidden = false;
[window addSubview:myViewController1.view];
[UIView commitAnimations];
}
我还启用了一个按钮以返回到正常的 cocos 游戏并删除 UIView,但在返回时,即使我的主要游戏方向已更改为纵向。
有任何想法吗???