在自定义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];
}
本文介绍如何在自定义UITableViewCell中使用代理模式来处理按钮点击事件。通过定义代理协议并在TableViewCell中发送通知给代理对象,实现了TableViewCell与外部ViewController之间的通信。
5340

被折叠的 条评论
为什么被折叠?



