小编Md *_*man的帖子

使用滑动手势在标签栏之间导航

我想使用滑动手势在我的标签栏之间导航.最简单的方法是什么?我试过这样的事......

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) {

        }
}
Run Code Online (Sandbox Code Playgroud)

如果我试图向右滑动没有任何反应.滑动时,应用程序崩溃以下错误消息

无法识别的选择器发送到实例0x7f924380a730

swipe ios swift swift3 xcode8

6
推荐指数
1
解决办法
7218
查看次数

标签 统计

ios ×1

swift ×1

swift3 ×1

swipe ×1

xcode8 ×1