iOS determines whether a cell of UITableView has been removed from the screen

1. Mark the NSIndexPath of the cell to be operated
NSIndexPath * optionIndexPath;

scrollViewDidScroll 里判断
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

if (optionIndexPath != nil) {
  //标记的cell  在tableView中的坐标值
    CGRect  recttIntableview = [_demoTable rectForRowAtIndexPath:optionIndexPath];
    //当前cell在屏幕中的坐标值
    CGRect rectInSuperView = [_demoTable convertRect:recttIntableview toView:[_demoTable superview]];
    
    //滑动到了屏幕下方
    if ( rectInSuperView.origin.y > self.view.frame.size.height) {
        // 对已经移出屏幕的 Cell 做相应的处理
       

    }else if (rectInSuperView.origin.y + rectInSuperView.size.height < 0){
        //当前操作的cell高度  rectInSuperView.size.heigt
        //滑动到了屏幕上方
       
        
    }else{
       
    }
    
    
}

}

Related Posts