How to Auto call an @IBAction function

前端 未结 3 1249
名媛妹妹
名媛妹妹 2021-02-19 21:17

Hi I am not sure how to do auto call a click-function for an @IBAction in Swift.

Say, I have a timer function, when countdown is finished, I need to call the Click-funct

3条回答
  •  情书的邮戳
    2021-02-19 22:07

    Do the same thing as @Moritz said but instead

    @IBAction func doSomeTask(sender: UIButton? = nil) {
        // code
    }
    

    so that way, you do something like:

     `doSomeTask()`
    

    which is saying the same thing as saying

     `doSomeTask(sender:nil)
    

    or pass an UIButton object if you so wish so.

     doSomeTask(sender:SomeUIButton)
    

提交回复
热议问题