3

I'm trying to code a feed so it's just a basic UITableView with one row per section and as many sections as posts. If I select a cell the tableView displays a cell in the row 1 in the same section than the selected cell, and if I re-select the cell or scroll the tableView the row 1 is deleted.

The problem is that if i select the first cell and then scroll to the bottom (like a pull to refresh), the tableView scroll while the animation of the deleting cell is done then at the end of the animation jumps to the top of the screen and then return where he was.

I don't know if that was clear.

Here's my scrollViewDidScroll

def scrollViewDidScroll(scroll_view)
    return if @can_scroll_comments
    hide_comments unless @comment_triggered_for == -1
  end

  def hide_comments
    feed_view = layout.get(:feed_view)

    section = @comment_triggered_for
    @comment_triggered_for = -1
    feed_view.deleteRowsAtIndexPaths([NSIndexPath.indexPathForRow(1, inSection: section)], withRowAnimation: UITableViewRowAnimationFade)
  end

in objective-c it should be something like

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (_can_scroll_comments) {
        return ;
    }
    if (_comment_triggered_for != -1) {
        [self hide_comments];
    }
}

- (void)hide_comments: {
    section = _comment_triggered_for
    _comment_triggered_for = -1
    [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:1 inSection:section]] withRowAnimation:UITableViewRowAnimationFade];
 }

Thanks for the help :)

Cacoa
  • 31
  • 2
  • you can use begin update, stop update of uitableview – BHASKAR Aug 21 '14 at 16:29
  • I tried with the begin & end updates but it didn't change anything :/ – Cacoa Aug 21 '14 at 19:46
  • Below link will help you out : [tabeview jumping on endupdate](http://stackoverflow.com/questions/28917923/uitableview-jumping-to-top-on-endupdates-while-typing-inside-a-cell-on-ios-8-aut/38582892#38582892) – Manoj Jul 27 '16 at 04:42

0 Answers0