简体   繁体   中英

UITableView delete rows without scrolling

I am building a feed of unseen images image.seen = 0

I have a NSFetchedResultsController bundled with a UITableViewController .

I am marking image.seen = 1 at tableView:didEndDisplayingCell:forRowAtIndexPath .

when my users scrolls to row2 containing image2, image1 will be updated and row1 will be deleted.

case NSFetchedResultsChangeDelete:

    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                         withRowAnimation:UITableViewRowAnimationFade];

    break;

however, when you delete row1, the UITableView will remember that you are currently at scroll position 1 from the top and maintain that scrolling position for you when the deletion occurs.

hence, you will get scrolled to row3. row2 now goes out of view and gets deleted. when deletion is complete, table will scroll you to row4....

How can I get around this?

如果要从外部删除行,可以从canEditRowAtIndexPath tableview委托中删除行,如果从数组加载,则根据tableView的行号从数组中的特定索引中删除已重新记录的内容,然后重新加载数据。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM