Why can't I call my function with gestureTapRecogniser

前端 未结 1 364
萌比男神i
萌比男神i 2021-01-28 16:21

I have this simple function that when someone taps the screen, the code inside the function executes, I know the code in the function works and I get no error when it is typed.<

1条回答
  •  滥情空心
    2021-01-28 17:15

    Just change

    reload()
    

    to

    reload(gestureRecognizer: nil)
    

    and reload method parameter should be UITapGestureRecognizer? optional.

    func reload(gestureRecognizer: UITapGestureRecognizer?) {
            let skView = self.view!
            skView.presentScene(scene)
    }
    

    Another short way is

    change action method that declared with UITapGestureRecognizer

    ...action: #selector(self.reload())...
    

    means remove (_:) no need to do anythings more just call reload() function.

    0 讨论(0)
提交回复
热议问题