Get UITableViewCell of UIButton?

前端 未结 2 1399
北海茫月
北海茫月 2021-01-28 17:56

I\'m trying to perform a segue using a UIButton, which is located within in a custom UITableViewCell class called GFHomeCell.

The

2条回答
  •  逝去的感伤
    2021-01-28 18:28

    Well, one answer would be to just go up a level in the view hierarchy:

     - (void)commentButtonClick:(id)sender {
        GFHomeCell * cell = (GFHomeCell *) [(UIButton*)sender superview];
        if (cell && [cell Class] == [GFHomeCell class]) {
            //do whatever with cell.postID
            [self performSegueWithIdentifier:@"addCommentSegue" sender:sender];
         }
    }
    

    Oh, I forget... you may have to go up two levels to get past the contentView property:

       GFHomeCell * cell = (GFHomeCell *) [[(UIButton*)sender superview] superview];
    

提交回复
热议问题