Getting UITableViewCell with superview in iOS 7

前端 未结 5 2026
栀梦
栀梦 2021-01-04 20:18

I\'m getting the UITableViewCell a UIButton belongs to like this:

-(void)buttonHandler:(UIButton *)button {

    OrderCell *cell = [[button superview] superv         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-04 21:00

    The best way to do this is:

    CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonPosition];
    UITableViewCell *cell = (UITableViewCell*)[self.tableView cellForRowAtIndexPath:indexPath];
    

提交回复
热议问题