我想使用滑动手势在标签栏控制器之间导航,同时保留默认标签栏.我使用此代码但显示错误.
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)