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

[你的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)