首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用GKPeerPickerController连接两台设备

使用GKPeerPickerController连接两台设备
EN

Stack Overflow用户
提问于 2011-01-20 16:41:47
回答 2查看 747关注 0票数 1

我有三个设备(mac、ipod、iphone),它们都连接到了wi-fi。当我测试连接两个设备的应用程序时,它们都要求打开蓝牙,但不管怎样,它们都想使用wi-fi。如何迫使他们使用蓝牙而不是wi-fi。

代码语言:javascript
复制
GKPeerPickerController*     picker;
picker = [[GKPeerPickerController alloc]init];
picker.delegate = self;
picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby; //Here, I suppose, program should use BlueTooth(but it uses the same network).
[picker show];

但如果其中一台设备没有连接到wi-fi,一切都会正常工作。

为什么将connectionTypesMask设置为GKPeerPickerConnectionTypeNearby首先使用互联网连接,然后才使用蓝牙连接?如何强制只使用蓝牙?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-03-30 19:31:02

我找到的唯一方法是:关闭MacBook的机场,打开BT。

票数 0
EN

Stack Overflow用户

发布于 2013-06-17 22:12:18

GKPeerPickerController委托方法的这段代码来自Mark和LaMarche开始iOS 5开发:

代码语言:javascript
复制
-(GKSession*)peerPickerController:(GKPeerPickerController *)picker sessionForConnectionType:(GKPeerPickerConnectionType)type
{
GKSession *theSession;
if (type == GKPeerPickerConnectionTypeNearby)
{
    theSession = [[GKSession alloc] initWithSessionID:kTicTacToeSessionID displayName:nil sessionMode:GKSessionModePeer];
}
return theSession;
}

它将确保您只连接BT会话。在他们的示例项目中,peerPicker的一些隐藏功能会让设备要求您打开BlueTooth。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4744967

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档