After i set my initial ViewController manually in the AppDelegate.swift
my UISwipeGestureRecognizer is not working.
This is how my AppDelegate look like:
self.mainNavigationController = UINavigationController()
var mainController: UIViewController? = TineLineViewController()
self.mainNavigationController!.pushViewController(mainController!, animated: true)
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window!.rootViewController = mainController
self.window!.makeKeyAndVisible()
and this is how my UISwipeGestureRecognizer is set in the initial ViewController:
let postLeft : Selector = "postLeft:"
let postLeftSwipe = UISwipeGestureRecognizer(target: self, action: postLeft)
postLeftSwipe.direction = UISwipeGestureRecognizerDirection.Left
goToPostButton.addGestureRecognizer(postLeftSwipe)
And this is my postLeft
method which instantiate a new ViewController and navigate to it.
func postLeft(sender: AnyObject) {
println("left swipe to push...")
let secondViewController = PostCreateController()
self.presentViewController(secondViewController, animated: true, completion: nil)
}
When I swipe, the postLeft
method was called, I can see the println left swipe to push, but the application doesn't changed the view.
Does anybody have any solution to solve this issue?
Thank you!
UPDATE:
i change my postLeft method. and by the console i see my new viewController class instantiates but it's not showing up.
I think you don't set your navigationController correctly,
try this instead of self.navigationController!.pushViewController
let secondViewController = PostCreateController()
self.presentViewController(secondViewController, animated: true, completion: nil)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.