Jac*_*son 5 notifications cocoa-touch ios game-center
我有一个以非常简单的方式使用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;
}
};
Run Code Online (Sandbox Code Playgroud)
另外一条信息是,当出现此问题时,我的应用程序处于纵向方向.看起来如果我在横幅显示时将手机旋转90度,它通常会在风景中看起来,但在纵向看起来它看起来都是压扁的.这有助于解释它吗?
我想到了。我没有实现 PreferredInterfaceOrientationForPresentation 所以我这样做了
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
Run Code Online (Sandbox Code Playgroud)
而且我还确保supportedInterfaceOrientations返回UIInterfaceOrientationMaskPortrait(请注意,它返回UIInterfaceOrientationMASKPortrait而不仅仅是UIInterfaceOrientationPortrait)。之后一切正常。
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
171 次 |
| 最近记录: |