我想要使用不同动作的按钮。当我第一次点击按钮时,只应该更改按钮名称。当我再次点击时,我想显示第一个ViewController。使用不同动作的UIButton
我的问题是,当我第一次点击时,它立即显示第一个ViewController。你能帮我吗?
感谢
@IBAction func startPressed(sender: UIButton) {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc: ViewController1 = storyboard.instantiateViewControllerWithIdentifier("firstView") as! ViewController1
var m: Bool?
m = true
if (m == true) {
startPressed2.setTitle("Try Again", forState: .Normal)
m = false
}
if (m == false) {
self.presentViewController(vc, animated: true, completion: nil)
}
}
如果你不理解的范围和不同类型的变量的一生,看到我的书:http://www.apeth.com/ swiftBook/ch03.html#_variable_scope_and_lifetime – matt
我改变了现在,但我的问题是,当按钮名称改变时,它同时显示视图控制器。我不希望它在同一时间 – Michael
刷新此页面以查看我编辑的答案。 – matt