我想在定時器完成後執行一個segue,但是我無法得到segue執行。Swift NSTimer and shouldPerformSegueWndIdentifier issue
這裏是我的代碼
var timer = NSTimer()
@IBOutlet weak var imageView: UIImageView!
func buttonControls() {
self.imageView.image = UIImage(named: "image1.png")
self.timer = NSTimer(timeInterval: 1.0, target: self, selector: "shouldPerformSegueWithIdentifier:", userInfo: nil, repeats: false)
}
@IBAction func loginButton(sender: AnyObject) {
buttonControls()
}
@IBAction func signupButton(sender: AnyObject) {
buttonControls()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.imageView.image = UIImage(named: "image2.png")
}
override func shouldPerformSegueWithIdentifier(identifier: String?, sender: AnyObject?) -> Bool {
if identifier == "loginSegue" {
performSegueWithIdentifier("loginSegue", sender: self)
} else {
performSegueWithIdentifier("signupSegue", sender: self)
}
return true
}
我是新來的斯威夫特所以任何幫助,將不勝感激。
謝謝!
你的問題是什麼? –
一旦計時器運行,shouldPeformSegueWithIdentifier不會執行 – user3080228
您能詳細說明您想要達到的目標嗎? –