Detecting which UIButton was pressed in a UITableView

前端 未结 26 2917
小蘑菇
小蘑菇 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:52

    create an nsmutable array and put all button in that array usint[array addObject:yourButton];

    in the button press method

    -

     (void)buttonPressedAction:(id)sender
    {
        UIButton *button = (UIButton *)sender;
    
    for(int i=0;i<[yourArray count];i++){
    
    if([buton isEqual:[yourArray objectAtIndex:i]]){
    
    //here write wat u need to do
    
    }
    }
    

提交回复
热议问题