在自定义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
 
转自:http://blog.sina.com.cn/s/blog_708663ad010153ul.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2021-11-22
  • 2022-12-23
  • 2021-07-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2021-09-02
  • 2022-12-23
  • 2021-12-28
相关资源
相似解决方案