我正在将UIFeedback Haptic Engine swift 2.3 一起使用,例如:

let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(.Warning)


let generator = UIImpactFeedbackGenerator(style: .Heavy)
generator.impactOccurred()

今天,我遇到了这样的新错误,却找不到问题。你有什么主意吗?
UIFeedbackHapticEngine _deactivate] called more times than the feedback engine was activated

细节:
Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x1863e41c0 __exceptionPreprocess
1  libobjc.A.dylib                0x184e1c55c objc_exception_throw
2  CoreFoundation                 0x1863e4094 +[NSException raise:format:]
3  Foundation                     0x186e6e82c -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4  UIKit                          0x18cc43fb8 -[_UIFeedbackEngine _deactivate]
5  UIKit                          0x18cad781c -[UIFeedbackGenerator __deactivateWithStyle:]

最佳答案

UIImpactFeedbackGenerator不是线程安全的,因此请确保您正在同步调用generator.impactOccurred(),而不是在dispatch_async或另一个异步线程中。

关于ios - UIFeedback触觉引擎被调用的次数多于被激活的次数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40273911/

10-10 13:38