美文网首页
点击cell里的Btn获取当前的index

点击cell里的Btn获取当前的index

作者: L_Divano | 来源:发表于2017-08-21 10:37 被阅读0次

[你的btn addTarget:selfaction:@selector(cellBtnClicked:event:) forControlEvents:UIControlEventTouchUpInside];


- (void)cellBtnClicked:(id)sender event:(id)event{

    NSSet*touches =[event allTouches];

    UITouch *touch =[touches anyObject];

    CGPoint currentTouchPosition = [touch locationInView:你的UITableView];

    NSIndexPath*indexPath= [你的UITableView indexPathForRowAtPoint:currentTouchPosition];

    //UICollectionView使用这句 NSIndexPath*indexPath= [你的UICollectionView     indexPathForItemAtPoint:currentTouchPosition];

    if(indexPath!=nil)  {

        // do something

      }

}

相关文章

网友评论

      本文标题:点击cell里的Btn获取当前的index

      本文链接:https://www.haomeiwen.com/subject/pplcdxtx.html