0
我在AppDelegate.swift
手動設置我的初始ViewController後,我的UISwipeGestureRecognizer無法正常工作。UISwipeGestureRecognizer無法手動設置初始ViewController後工作
這是我的AppDelegate什麼樣子:
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()
,這是我UISwipeGestureRecognizer是如何在初始視圖控制器設置:
let postLeft : Selector = "postLeft:"
let postLeftSwipe = UISwipeGestureRecognizer(target: self, action: postLeft)
postLeftSwipe.direction = UISwipeGestureRecognizerDirection.Left
goToPostButton.addGestureRecognizer(postLeftSwipe)
這是我postLeft
方法,實例化一個新的ViewController並導航到它。
func postLeft(sender: AnyObject) {
println("left swipe to push...")
let secondViewController = PostCreateController()
self.presentViewController(secondViewController, animated: true, completion: nil)
}
當我刷卡時,postLeft
方法被調用,我可以看到向左掃推的println,但應用程序不會改變的觀點。
有沒有人有任何解決方案來解決這個問題?
謝謝!
更新:
我改變我的postLeft方法。並通過控制檯,我看到我的新viewController類實例化,但它沒有顯示出來。
它拋出這個:警告:試圖提出「在其視圖不在窗口層次結構中!「和新的視圖沒有顯示:( –
solarenqu
檢查,你是不是指出該視圖performSegueWithIdentifer:發件人也 –
我沒有任何performSegueWithIdentifer方法..我沒有故事板neihter .. – solarenqu