Desplazamiento desigual después de actualizar UITableViewCell en su lugar con UITableViewAutomaticDimension

Estoy creando una aplicación que tiene una vista de feed para las publicaciones enviadas por los usuarios. Esta vista tiene unUITableView con una costumbreUITableViewCell implementación. Dentro de esta celda, tengo otroUITableView para mostrar comentarios. La esencia es algo como esto:

Feed TableView
  PostCell
    Comments (TableView)
      CommentCell
  PostCell
    Comments (TableView)
      CommentCell
      CommentCell
      CommentCell
      CommentCell
      CommentCell

El feed inicial se descargará con 3 comentarios para obtener una vista previa, pero si hay más comentarios, o si el usuario agrega o elimina un comentario, quiero actualizar elPostCell en su lugar dentro de la vista de la tabla de alimentación agregando o quitandoCommentCells a la tabla de comentarios dentro de laPostCell. Actualmente estoy usando el siguiente ayudante para lograr eso:

// (PostCell.swift) Handle showing/hiding comments
func animateAddOrDeleteComments(startRow: Int, endRow: Int, operation: CellOperation) {
  let table = self.superview?.superview as UITableView

  // "table" is outer feed table
  // self is the PostCell that is updating it's comments
  // self.comments is UITableView for displaying comments inside of the PostCell
  table.beginUpdates()
  self.comments.beginUpdates()

  // This function handles inserting/removing/reloading a range of comments
  // so we build out an array of index paths for each row that needs updating
  var indexPaths = [NSIndexPath]()
  for var index = startRow; index <= endRow; index++ {
    indexPaths.append(NSIndexPath(forRow: index, inSection: 0))
  }

  switch operation {
  case .INSERT:
    self.comments.insertRowsAtIndexPaths(indexPaths, withRowAnimation: UITableViewRowAnimation.None)
  case .DELETE:
    self.comments.deleteRowsAtIndexPaths(indexPaths, withRowAnimation: UITableViewRowAnimation.None)
  case .RELOAD:
    self.comments.reloadRowsAtIndexPaths(indexPaths, withRowAnimation: UITableViewRowAnimation.None)
  }

  self.comments.endUpdates()
  table.endUpdates()

  // trigger a call to updateConstraints so that we can update the height constraint 
  // of the comments table to fit all of the comments
  self.setNeedsUpdateConstraints()
}

override func updateConstraints() {
  super.updateConstraints()
  self.commentsHeight.constant = self.comments.sizeThatFits(UILayoutFittingCompressedSize).height
}

Esto logra la actualización muy bien. La publicación se actualiza en su lugar con comentarios agregados o eliminados dentro delPostCell como se esperaba. Estoy usando el dimensionamiento automáticoPostCells en la mesa de alimentación. La tabla de comentarios de laPostCell se expande para mostrar todos los comentarios, pero la animación es un poco irregular y la tabla se desplaza hacia arriba y hacia abajo una docena de píxeles más o menos mientras se realiza la animación de actualización de celda.

El salto durante el cambio de tamaño es un poco molesto, pero mi problema principal viene después. Ahora, si me desplazo hacia abajo en el feed, el desplazamiento es suave como antes, pero si me desplazo hacia arriba por encima de la celda que acabo de cambiar de tamaño después de agregar comentarios, el feed saltará hacia atrás varias veces antes de llegar a la parte superior del feed. ConfiguroiOS8 celdas de tamaño automático para el Feed de esta manera:

// (FeedController.swift)
// tableView is the feed table containing PostCells
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.estimatedRowHeight = 560

Si elimino elestimatedRowHeight, la tabla solo se desplaza hacia arriba cada vez que cambia la altura de una celda. Me siento bastante atrapado en esto ahora y, como nuevo desarrollador de iOS, podría usar cualquier consejo que pueda tener.

Respuestas a la pregunta(6)

Su respuesta a la pregunta