【发布时间】:2018-10-02 08:30:03
【问题描述】:
我正在使用来自 github 的这个开源项目:https://github.com/barnaclejive/FaceTrigger
我无法在子类中解决这个错误:
错误:在调用“super.init”之前,方法调用“onBoth”中使用了“self”
class BrowDownEvaluator: BothEvaluator {
func onBoth(delegate: FaceTriggerDelegate, newBoth: Bool) {
delegate.onBrowDownDidChange?(browDown: newBoth)
if newBoth {
delegate.onBrowDown?()
}
}
func onLeft(delegate: FaceTriggerDelegate, newLeft: Bool) {
}
func onRight(delegate: FaceTriggerDelegate, newRight: Bool) {
}
init(threshold: Float) {
super.init(threshold: threshold, leftKey: .browDownLeft, rightKey: .browDownRight, onBoth: onBoth, onLeft: onLeft, onRight: onRight)
}
}
父类:
class BothEvaluator: FaceTriggerEvaluatorProtocol {
private let threshold: Float
private let leftKey: ARFaceAnchor.BlendShapeLocation
private let rightKey: ARFaceAnchor.BlendShapeLocation
private var onBoth: (FaceTriggerDelegate, Bool) -> Void
private var onLeft: (FaceTriggerDelegate, Bool) -> Void
private var onRight: (FaceTriggerDelegate, Bool) -> Void
private var oldLeft = false
private var oldRight = false
private var oldBoth = false
init(threshold: Float,
leftKey: ARFaceAnchor.BlendShapeLocation ,
rightKey: ARFaceAnchor.BlendShapeLocation ,
onBoth: @escaping (FaceTriggerDelegate, Bool) -> Void,
onLeft: @escaping (FaceTriggerDelegate, Bool) -> Void,
onRight: @escaping (FaceTriggerDelegate, Bool) -> Void)
{
self.threshold = threshold
self.leftKey = leftKey
self.rightKey = rightKey
self.onBoth = onBoth
self.onLeft = onLeft
self.onRight = onRight
}
我知道我必须在这里初始化 onBoth 和其余方法但是您如何初始化该方法?我还在学习 Swift。
【问题讨论】:
标签: swift