UINavigationController

UINavigationController

我正在使用Redpark Serial SDK 1.4 r270帮助iphone的I / O功能。我目前遇到的问题之一是读取使用给出的数据

- (void) readBytesAvailable:(UInt32)numBytes {

这是我的错误。
Feb  8 15:27:50  iapd[897] <Warning>: ERROR - /SourceCache/iapd/iapd-1065.23/iapd/IAPSession.mm:-[IAPSessionBasic _sessionBufferToAppHasSpaceAvailable] - 823 session=0x1 for connectionID=0x1e12ea00 failed to write bytes, errno = 32
Feb  8 15:27:50  iOS[7428] <Warning>: ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213/EASession.m:-[EASession dealloc] - 137 unable to close session for _accessory=0x20047eb0 and sessionID=65536
Feb  8 15:27:50  iOS[7428] <Warning>: ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213/EAOutputStream.m:-[EAOutputStream write:maxLength:] - 212 failed to write 229 bytes (wrote -1) with error 9
Feb  8 15:27:50  iOS[7428] <Warning>: ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213/EAInputStream.m:-[EAInputStream _readInputFromAccThread] - 357 error waiting for read data, errno = 9

这与单视图应用程序完美配合。

假设有一个UINavigationController,它具有视图A和视图B,单击按钮时其中A =>B。视图B使用的是RscMgr线程,所有魔术都从串行端口读取。
在视图B的UINavigationController的第一个实例中,如果我们停留在该视图上,它会很好地工作。我们能够断开连接,连接端口,然后我们将继续流数据。

但是,如果我返回视图A,然后返回视图B。一切都会陷入困境。我无法再通过此功能读取数据,并且在控制台中发现了(MULTIPLE)错误。是否有人有充分的理由说明为什么会发生这种情况以及我们如何解决它?我知道我们已经从堆栈中弹出了UIViewController,并且一切都重置了,并且再次创建了RscMgr线程,但是什么也没有查看。我不确定如何使用SDK清除缓冲区,因为未提供它。

最佳答案

您声明的范围

- (void) readBytesAvailable:(UInt32)numBytes {

可能是问题所在。我会在打开和关闭B时声明不会消失的位置。例如在UINavigationController或AppDelegate上。

更好的是,创建一个新的Singleton类来管理RedPark的接口,并根据需要从应用程序的其余部分查询它。

10-08 00:42