我正在为我的项目将可用的Swift代码移植到Xamarin。每次调用此函数时,它都会失败并且附件选择器对话框不会显示。
EAAccessoryManager.SharedAccessoryManager.ShowBluetoothAccessoryPicker(predicate, completion)
以下是一些我已确认的事项:
- BT无线电打开 - Info.plist有“支持的外部配件协议” - 尝试确保在UI线程上进行调用 - 尝试直接从按钮单击事件调用 - 在Swift/Xcode中相同的基本代码运行良好 - 确保根据此文章在构建选项中选择了ARMv7和ARM64:iPad Air - CoreBluetooth[ERROR] Cancelling picker as we couldn't communicate with Bluetooth Xamarin:
Xamarin代码无法显示选择器并且始终会失败。
EAAccessoryManager.SharedAccessoryManager.ShowBluetoothAccessoryPicker(predicate, completion)
以下是一些我已确认的事项:
- BT无线电打开 - Info.plist有“支持的外部配件协议” - 尝试确保在UI线程上进行调用 - 尝试直接从按钮单击事件调用 - 在Swift/Xcode中相同的基本代码运行良好 - 确保根据此文章在构建选项中选择了ARMv7和ARM64:iPad Air - CoreBluetooth[ERROR] Cancelling picker as we couldn't communicate with Bluetooth Xamarin:
EAAccessoryManager.SharedAccessoryManager.ShowBluetoothAccessoryPicker(null, completion: ((Foundation.NSError error) => {
Console.WriteLine("My callback");
if (error != null) {
Console.WriteLine(String.Format("Error code: {0} Desc: {1}", error.Code, error.DebugDescription));
Console.WriteLine("Failed? " + EABluetoothAccessoryPickerError.Failed.ToString());
Console.WriteLine("Failed? " + Convert.ToInt64(EABluetoothAccessoryPickerError.Failed));
}
}));
Xcode / Swift:
EAAccessoryManager.sharedAccessoryManager().showBluetoothAccessoryPickerWithNameFilter(nil) { (error) -> Void in
if error != nil {
NSLog("Error code: \(error!.code) \(error.debugDescription)")
}
}
Xamarin代码无法显示选择器并且始终会失败。
2016-04-05 19:54:02.136 ASGDemo.iOS[6383:2146384] Connect Clicked
2016-04-05 19:54:06.139 ASGDemo.iOS[6383:2146384] BTM: attaching to BTServer
2016-04-05 19:54:09.157 ASGDemo.iOS[6383:2146384] BTM: session attach called back with BT_SESSION_ATTACHED (fffffed0)
2016-04-05 19:54:09.158 ASGDemo.iOS[6383:2146384] BTM: attemping to re-attach in 1 seconds
2016-04-05 19:54:09.242 ASGDemo.iOS[6383:2146384] My callback
2016-04-05 19:54:09.250 ASGDemo.iOS[6383:2146384] Error code: 3 Desc: Error Domain=EABluetoothAccessoryPickerErrorDomain Code=3 "(null)"
2016-04-05 19:54:09.253 ASGDemo.iOS[6383:2146384] Failed? Failed
2016-04-05 19:54:09.254 ASGDemo.iOS[6383:2146384] Failed? 3