相关疑难解决方法(0)

想要在swift中使用滑动gesters在标签栏之间导航

我想使用滑动手势在标签栏控制器之间导航,同时保留默认标签栏.我使用此代码但显示错误.

import UIKit

 class FirstViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()


        var leftSwipe = UISwipeGestureRecognizer(target: self, action: Selector("handleSwipes:"))


        leftSwipe.direction = .Left


        view.addGestureRecognizer(leftSwipe)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.

        func handleSwipes(sender:UISwipeGestureRecognizer) {
            if (sender.direction == .Left) {

                let storyboard = UIStoryboard(name: "Main", bundle: nil)
                let vc = storyboard.instantiateViewControllerWithIdentifier("SecondViewController") as! UIViewController
                self.presentViewController(vc, animated: false, completion: nil)

            }

            if (sender.direction == .Right) {

            }
        }


    }


}
Run Code Online (Sandbox Code Playgroud)

uitabbarcontroller ios swift

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

标签 统计

ios ×1

swift ×1

uitabbarcontroller ×1