ios - 使用 Gamekit 时如何通过 WiFi 建立连接?

标签 ios wifi p2p gamekit

我想使用 GameKit 通过 WiFi 在两个设备之间建立连接。苹果的文档说

If an Internet connection is chosen, your application must dismiss the peer picker dialog and present its own user interface to complete the connection.

我就是这样做的

- (void)peerPickerController:(GKPeerPickerController *)picker didSelectConnectionType:(GKPeerPickerConnectionType)type
{
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];
}
}

好的,我已经展示了我自己的界面。接下来呢?我如何连接?如何开始寻找同行?

最佳答案

tutorial使用 Gamekit 和蓝牙或 wifi 构建点对点纸牌游戏。 (链接已更新)

关于ios - 使用 Gamekit 时如何通过 WiFi 建立连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10862670/

相关文章:

ios - 访问未配置的 YouTube API

ios - 没有看到 20 个 I/O 周期;下载音频文件时放弃在 Swift 中发生

ios - 使用 Multipeer Connectivity wifi/蓝牙发送 UISlider 值

ios - 图像在运行时自动调整大小但不在 Interface Builder 上

ios - 如何确定用户何时复制了文本

android - 帮助点对点wifi

java - 缺少 Android 网络连接状态。

python - 用于私有(private)文件传输的 bittorrent 跟踪器服务器 - python

java - NAT 后面的两台主机使用什么协议(protocol)进行 P2P 文件传输?

p2p - peer2peer如何通过路由器工作?