Can't pass arguments into @selector methods?

前端 未结 2 1030
[愿得一人]
[愿得一人] 2021-01-22 03:36

I\'m currently trying to use a UIButton titled \"X\" as a way to remove a Sprite from the view.

Basically, my code works so that when a Sprite is touched, a message is s

2条回答
  •  鱼传尺愫
    2021-01-22 04:19

    A selector is simply a method identifier, not an invocation of the method, so you can't include parameters as though it were a method call.

    The usual way to manage something like this would be for the view controller to look at the button that was touched, figure out which sprite it's associated with, and remove the sprite. It was probably the view controller that put both the sprite and the button in the view in the first place, so it should have all the information it needs.

提交回复
热议问题