2011-01-20 61 views
1


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

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

回答

0

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

0

此代码为GKPeerPickerController委托方法是由马克和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的一些隐藏功能使设备要求您打开蓝牙。