GameKit WiFi可在模拟器上运行,但不适用于设备

时间:2012-06-05 10:15:56

标签: iphone wifi p2p gamekit gksession

使用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];
}

0 个答案:

没有答案