Detecting which UIButton was pressed in a UITableView

前端 未结 26 2929
小蘑菇
小蘑菇 2020-11-22 00:40

I have a UITableView with 5 UITableViewCells. Each cell contains a UIButton which is set up as follows:

- (UITableView         


        
26条回答
  •  一整个雨季
    2020-11-22 00:45

    Am I missing something? Can't you just use sender to identify the button. Sender will give you info like this:

    >
    

    Then if you want to change the properties of the button, say the background image you just tell sender:

    [sender setBackgroundImage:[UIImage imageNamed:@"new-image.png"] forState:UIControlStateNormal];
    

    If you need the tag then ACBurk's method is fine.

提交回复
热议问题