Я пытаюсь добавить код жеста для пролистывания вверх / вниз к своему UIViewController
в приложении tvOS.
override func loadView() {
let swipeDown = UISwipeGestureRecognizer(
target: self,
action: #selector(self.respondToSwipeGesture)
)
swipeDown.direction = UISwipeGestureRecognizer.Direction.down
self.view.addGestureRecognizer(swipeDown)
let swipeUp = UISwipeGestureRecognizer(
target: self,
action: #selector(self.respondToSwipeGesture)
)
swipeUp.direction = UISwipeGestureRecognizer.Direction.up
self.view.addGestureRecognizer(swipeUp)
}
@objc private func respondToSwipeGesture(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizer.Direction.down:
print("Swiped down")
case UISwipeGestureRecognizer.Direction.up:
print("Swiped up")
default:
break
}
}
}
При запуске я получаю
Поток 1: EXC_BAD_ACCESS (код = 2, адрес = 0x7ffee7146fe8)
в строке let swipeDown
в функции loadView
.
Я использую Xcode 11. Чтоя здесь скучаю?