在自定义UITableViewCell中创建了一个按钮。
[but setFrame:CGRectMake(280, 10, 30, 30)];
[but setAlpha:0.8];
[but addTarget:self action:@selector(del:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:but];
//设置Tag为cell 对应的indexPath row
for(id view in subviews)
{
if([view isKindOfClass:[UIButton class]])
{
[view setTag:[indexPath row]];
//[cell.contentView bringSubviewToFront:view];
}
}
}
//Button事件
-(void)del:(id)sender
{
for(UITableViewCell *cell in visiblecells)
{
if(cell.tag == button.tag)
{
//button.tag就是对应的[indexPath.row
}
[but setAlpha:0.8];
[but addTarget:self action:@selector(del:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:but];
//设置Tag为cell 对应的indexPath row
for(id view in subviews)
{
if([view isKindOfClass:[UIButton class]])
{
[view setTag:[indexPath row]];
//[cell.contentView bringSubviewToFront:view];
}
}
}
//Button事件
-(void)del:(id)sender
{
for(UITableViewCell *cell in visiblecells)
{
if(cell.tag == button.tag)
{
//button.tag就是对应的[indexPath.row
}
转自:http://blog.sina.com.cn/s/blog_708663ad010153ul.html