1、给控件添加tag值
- (void)Report:(LSXCommunityCell *)cell{
self.dropView = [[PGGDropView alloc] initWithFrame:CGRectMake(200, 150 ,100, 200) withTitleArray:@[@"屏蔽此信息",@"举报该用户"]];
[self.dropView beginAnimation];
self.dropView.delegate = self;
self.dropView.tag=100;
[cell.contentView addSubview:self.dropView];
}
2、在-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath方法中,添加
[[cell viewWithTag:100] removeFromSuperview];
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
// 通过indexPath创建cell实例 每一个cell都是单独的
LSXCommunityCell *cell=[tableView dequeueReusableCellWithIdentifier:_Identifier];
[[cell viewWithTag:100] removeFromSuperview];
if (cell == nil) {
//重构Cell的时候,通过 _Identifier判断是否创建打电话按钮
cell = [[LSXCommunityCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:_Identifier];
}
[[cell viewWithTag:100] removeFromSuperview];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
cell.delegate=self;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
if(self.dataArray.count>0){
_model =self.dataArray[indexPath.row];
cell.Model=_model;
__weak typeof(self) weakSelf = self;
cell.ReportBlock = ^(LSXCommunityCell *cell) {
[weakSelf Report:cell];
};
cell.CommunityIdBlock = ^(NSString *str) {
_idStr =str;
};
cell.bjbrPhoneBlock = ^(NSString *str) {
_bjbrPhoneStr=str;
};
}
return cell;
}