请记住,您必须实现以下两种方法才能在更改时收到通知。
下面是我的简单版本..所以基本上你不能开始网络游戏,或者在被识别为按钮被隐藏之前查看梯子:)
- (void) registerForAuthenticationNotification
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver: self
selector:@selector(authenticationChanged)
name:GKPlayerAuthenticationDidChangeNotificationName
object:nil];
}
- (void) authenticationChanged
{
if ([GKLocalPlayer localPlayer].isAuthenticated)
{
[networkGame setHidden:NO];
[ladder setHidden:NO];
}
else
{
[networkGame setHidden:YES];
[ladder setHidden:YES];
}
}