【发布时间】:2017-05-28 20:35:51
【问题描述】:
我想使用滑动手势在标签栏之间导航。最简单的方法是什么?我尝试过这样的事情......
import UIKit
class postAdViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
var leftSwipe = UISwipeGestureRecognizer(target: self, action: Selector("handleSwipes:"))
view.addGestureRecognizer(leftSwipe)
}
func handleSwipes(sender:UISwipeGestureRecognizer) {
if (sender.direction == .left) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "favourireviewcontroller") as! UIViewController
self.present(vc, animated: true, completion: nil)
}
if (sender.direction == .right) {
}
}
如果我尝试向右滑动,则没有任何反应。滑动时应用崩溃并留下以下错误消息
无法识别的选择器发送到实例 0x7f924380a730
【问题讨论】:
标签: ios swift swift3 xcode8 swipe