gpt4 book ai didi

ios - GameCenter 通知横幅有时会出现 "squished"- 这可能是什么原因造成的?

转载 作者:可可西里 更新时间:2023-11-01 04:46:54 25 4
gpt4 key购买 nike

我有一个以非常简单的方式使用 GameCenter 的应用程序(只是一个历史最高分的简单排行榜)。有时,当我切换到我的应用程序时,我会看到“欢迎回到游戏中心”的通知,但有时该通知会被压扁,如下图所示:

http://i.imgur.com/KOCFIJo.jpg

有谁知道这可能是什么原因造成的?因为我完全不知道。

我生成通知横幅的身份验证代码是相当标准的。

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];

[GKLocalPlayer localPlayer].authenticateHandler = ^(UIViewController *viewController, NSError *error) {
// If there is an error, do not assume local player is not authenticated.
if (localPlayer.isAuthenticated) {

// Enable Game Center Functionality
self.gameCenterAuthenticationComplete = YES;
[self enableGameCenter:YES];
gameCenterButton.enabled=true;

} else {
NSLog(@"game center not logged in");
// User has logged out of Game Center or can not login to Game Center, your app should run
// without GameCenter support or user interface.
self.gameCenterAuthenticationComplete = NO;
[self enableGameCenter:NO];
[self presentViewController:viewController animated:true completion:nil ];
gameCenterButton.enabled=false;

}
};

另外一条信息是,出现此问题时我的应用程序处于纵向。似乎如果我在显示横幅时将手机旋转 90 度,它在风景中看起来很正常,但在肖像中看起来全都被压扁了。这有助于解释吗?

最佳答案

我想通了。我没有实现 preferredInterfaceOrientationForPresentation 所以我这样做了

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}

我还确保 supportedInterfaceOrientations 返回 UIInterfaceOrientationMaskPortrait(注意它返回 UIInterfaceOrientationMASKPortrait 而不仅仅是 UIInterfaceOrientationPortrait)。之后一切正常。

- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}

关于ios - GameCenter 通知横幅有时会出现 "squished"- 这可能是什么原因造成的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19746994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com