Passing parameters on button action:@selector

前端 未结 11 1309
生来不讨喜
生来不讨喜 2020-11-27 17:29

I want to pass the movie url from my dynamically generated button to MediaPlayer:

[button addTarget:self action:@selector(buttonPressed:) withObject:[speaker         


        
11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 17:54

    UIButton responds to addTarget:action:forControlEvents: since it inherits from UIControl. But it does not respond to addTarget:action:withObject:forControlEvents:

    see reference for the method and for UIButton

    You could extend UIButton with a category to implement that method, thought.

提交回复
热议问题