我有三个设备(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首先使用互联网连接,然后才使用蓝牙连接?如何强制只使用蓝牙?
发布于 2011-03-30 19:31:02
我找到的唯一方法是:关闭MacBook的机场,打开BT。
发布于 2013-06-17 22:12:18
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的一些隐藏功能会让设备要求您打开BlueTooth。
https://stackoverflow.com/questions/4744967
复制相似问题