1.cell点击效果————cell的框变颜色/xib自定义cell,重用池
<pre name="code" class="objc">-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"ManageTableViewCell";
ManageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:@"ManageTableViewCell" owner:self options:nil];
if (!cell) {
for (id view in nibs) {
if ([view isKindOfClass:[ManageTableViewCell class]]) {
cell = view;
}
}
}
cell.target = self;
cell.changeButtonAction = @selector(changeButtonAction:);
cell.changeBtn.tag = indexPath.row + 1;
cell.editButtonAction = @selector(editButtonAction:);
cell.editBtn.tag = indexPath.row + 1000;
cell.clearButtonAction = @selector(clearButtonAction:);
cell.clearBtn.tag = indexPath.row + 2000;
cell.nameLabel.text = @"大黑牛";
cell.phoneLabel.text = @"15534598900";
cell.addressLabel.text = @"大空间的开发基地开工大连市高科技的时各家各户飞机和飞机和飞机高";
cell.backgroundColor = [UIColor clearColor];
//----------------自定义选中cell时的背景颜色
UIView *selectedView = [[UIView alloc] initWithFrame:cell.background.frame];
selectedView.backgroundColor = [UIColor whiteColor];
selectedView.layer.borderColor = WORDS_COLOR.CGColor;
selectedView.layer.borderWidth = 1;
selectedView.layer.cornerRadius = 3;
cell.selectedBackgroundView = selectedView;
return cell;
}
2.cell上的按钮点击事件
@property (assign, nonatomic)SEL changeButtonAction;//修改默认
@property (assign, nonatomic)SEL clearButtonAction;//删除
@property (assign, nonatomic)SEL editButtonAction;//编辑
@property (assign, nonatomic)id target;
-(void)layoutSubviews{
[self.changeBtn addTarget:self.target action:self.changeButtonAction forControlEvents:UIControlEventTouchUpInside];
[self.clearBtn addTarget:self.target action:self.clearButtonAction forControlEvents:UIControlEventTouchUpInside];
// [self.clearPic addTarget:self.target action:self.clearButtonAction forControlEvents:UIControlEventTouchUpInside];
[self.editBtn addTarget:self.target action:self.editButtonAction forControlEvents:UIControlEventTouchUpInside];
// [self.editPic addTarget:self.target action:self.editButtonAction forControlEvents:UIControlEventTouchUpInside];
[self.changeBtn setBackgroundImage:[UIImage imageNamed:@"select_no.png"] forState:UIControlStateSelected];
}