继续说在代码中找不到方法endBlink的错误。任何人都可以帮我解决它吗?我认为是swift 3的新语法风格的选择器参数问题
private func endBlink(timer : Timer){
// some action to do
}
private func startBlink(){
faceView.eyeOpen = false
// wait a section then open eyes
Timer.scheduledTimer(timeInterval: 2.0,
target: self,
selector:self.endBlink(_:),
userInfo: nil,
repeats: false)
}
答案 0 :(得分:0)
试
@objc
func endBlink() {
}
private func startBlink(){
faceView.eyeOpen = false
// wait a section then open eyes
Timer.scheduledTimer(timeInterval: 2.0,
target: self,
selector:#selector(endBlink),
userInfo: nil,
repeats: false)
}
答案 1 :(得分:0)
删除第一个方法的“private”,并应用“#selector”:
func endBlink(timer:Timer){
// some action to do
}
private func startBlink(){
faceView.eyeOpen = false
// wait a section then open eyes
Timer.scheduledTimer(timeInterval: 2.0,
target: self,
selector:#selector(endBlink),
userInfo: nil,
repeats: false)
}