在自定义cell里面的.h 里面定义代理
@class SOS_TableViewCell;
@protocol SOS_TableViewCellDelegate <NSObject>
@required
- (void)didSelectButton:(UIButton *)button tabelViewcell:(SOS_TableViewCell *)SOScell;
@property(nonatomic,assign)id<SOS_TableViewCellDelegate>delegate;
在自定义cell里面的。m 里面实现代理
- (void)takePhone:(UIButton *)sender
{
[self.delegate didSelectButton:sender tabelViewcell:self];
}
导入代理SOS_TableViewCellDelegate
在tableview的类里面实现(记得给cell挂上代理)
//打电话
- (void)didSelectButton:(UIButton *)button tabelViewcell:(SOS_TableViewCell *)SOScell
{
// 取cell的indexPath
NSIndexPath *indexPath = [showListTable indexPathForCell:SOScell];
}