1. Обработка и добавление swipe-жеста
//...
let swipeRightRecognizer = UISwipeGestureRecognizer(target: self, action: Selector("onSwipe:"))
swipeRightRecognizer.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(swipeRightRecognizer)
}
func onSwipe(gesture: UIGestureRecognizer) {
if let swipe = gesture as? UISwipeGestureRecognizer {
switch swipe.direction {
case UISwipeGestureRecognizerDirection.Right:
println("right")
default:
break
}
}
}
2. Обработка и добавление shake-жеста
override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent) {
if motion == UIEventSubtype.MotionShake {
println("shake")
}
}
//...
let swipeRightRecognizer = UISwipeGestureRecognizer(target: self, action: Selector("onSwipe:"))
swipeRightRecognizer.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(swipeRightRecognizer)
}
func onSwipe(gesture: UIGestureRecognizer) {
if let swipe = gesture as? UISwipeGestureRecognizer {
switch swipe.direction {
case UISwipeGestureRecognizerDirection.Right:
println("right")
default:
break
}
}
}
2. Обработка и добавление shake-жеста
override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent) {
if motion == UIEventSubtype.MotionShake {
println("shake")
}
}
Комментариев нет:
Отправить комментарий