1


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

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 首先使用 Internet 连接,然后才使用蓝牙连接?如何强制只使用蓝牙?

4

2 回答 2

0

我发现这样做的唯一方法:关闭 MacBook 中的机场并打开 BT。

于 2011-03-30T11:31:01.610 回答
0

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

-(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 的一些隐藏功能使设备要求您打开蓝牙。

于 2013-06-17T14:12:18.390 回答