objective-c - IOS10 蓝牙打印,打印到一半截断
巴扎黑
巴扎黑 2017-04-18 09:54:59
0
2
625

做了一个蓝牙打印的app。
蓝牙连接没什么问题,但是打印出了一个问题
我使用如下代码将一个字符串打印出来

[_currentPeripheral writeValue:data forCharacteristic:_curcharacteristic type:CBCharacteristicWriteWithResponse];

如果我打印的字符串过长,总是打印到一半就打印不出来了。

我猜想这是IOS10的bug,因为之前这个程序在IOS9上并没有任何问题。

做过类似应用的朋友们,求问你们有没有遇到过这样的问题,最后你们是怎么解决的?

巴扎黑
巴扎黑

reply all(2)
Peter_Zhu

Bluetooth transmission is limited in data length and data cannot be sent to external devices all the time. You need to divide the data to be printed into multiple Data and send it to the peripheral device.

Ty80

You can use

- (NSUInteger)maximumWriteValueLengthForType:(CBCharacteristicWriteType)type; 

Look at the maximum length

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!