在使用 GameKit 时,我遇到了一个无法解释的问题。通过 WiFi ( picker.connectionTypesMask = GKPeerPickerConnectionTypeOnline;
) 建立连接时,设备无法互相看到。当模拟器看到一切时,他们什么也看不到,它可以看到任何设备或模拟器在不同的机器上工作。几天来,我一直在努力研究它,我已经试图理解为什么它可以在模拟器上运行,但不能在设备上运行。谁能帮帮我吗?
这就是我创建会话的方式
if (type == GKPeerPickerConnectionTypeOnline)
{
picker.delegate = nil;
[picker dismiss];
[picker autorelease];
[alert setTitle:@"\n\n\n"];
[alert setMessage:@"Looking for other iPads, iPhones or iPod touches..."];
[alert addButtonWithTitle:@"Cancel"];
UIActivityIndicatorView *progress = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)];
progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[alert addSubview:progress];
[progress startAnimating];
[alert show];
self.gameSession = [[GKSession alloc] initWithSessionID:kSessionID displayName:nil sessionMode:GKSessionModePeer];
self.gameSession.available = YES;
self.gameSession.delegate = self;
self.gameSession.disconnectTimeout = 0;
[self.gameSession setDataReceiveHandler:self withContext:nil];
}