Ios 评论系统(类似Facebook)的实施

Ios 评论系统(类似Facebook)的实施,ios,swift,uitableview,uikit,Ios,Swift,Uitableview,Uikit,我正在寻找一种方法来创建一个类似于Facebook的帖子评论部分的评论系统 现在我有这样的结构: 但是我还需要实现回复评论和回复回复回复等等。 要实现与Facebook相同的行为,应该做些什么?要实现刷到回复或删除等功能,请使用此库: 对于答复和删除,请执行以下操作: private func addFuncButtons(to cell: CommentCell, at row: Int) { let currentUserId = User.getCurrentUserId()

我正在寻找一种方法来创建一个类似于Facebook的帖子评论部分的评论系统

现在我有这样的结构:

但是我还需要实现回复评论和回复回复回复等等。
要实现与Facebook相同的行为,应该做些什么?

要实现刷到
回复
删除
等功能,请使用此库:

对于答复和删除,请执行以下操作:

private func addFuncButtons(to cell: CommentCell, at row: Int) {
  let currentUserId = User.getCurrentUserId()

  if (cell.comment.userId == currentUserId // if its current user comment
     || userId! == currentUserId) // if current user is post author
     && cell.comment.key != "" { // cant delete desc
     cell.rightButtons = [
        MGSwipeButton(title: "", icon: UIImage(named:"delete.png"), backgroundColor: .red) {
           (sender: MGSwipeTableCell!) -> Bool in
           self.removeCell(cell, at: row)
           return true
        },
        MGSwipeButton(title: "", icon: UIImage(named:"reply.png"), backgroundColor: .darkGray) {
           (sender: MGSwipeTableCell!) -> Bool in
           self.replyToUser(with: cell.userNickName.currentTitle!)
           return true
        }
     ]
  } else {
     // add only reply button
     cell.rightButtons = [
        MGSwipeButton(title: "", icon: UIImage(named:"reply.png"), backgroundColor: .darkGray) {
           (sender: MGSwipeTableCell!) -> Bool in
           self.replyToUser(with: cell.userNickName.currentTitle!)
           return true
        }
     ]
  }

  cell.rightSwipeSettings.transition = .rotate3D
}
行动:

private func removeCell(_ cell: CommentCell, at row: Int) {
  removeCellFromTable(cell, at: row)
  removeCellFromDataBase(cell)
}

private func removeCellFromTable(_ cell: CommentCell, at row: Int) {
   comments.remove(at: row)
   tableView.reloadData()
}

private func removeCellFromDataBase(_ cell: CommentCell) {
   Comment.remove(cell.comment, from: post)
}

private func replyToUser(with login: String) {
   newCommentTextField.text = newCommentTextField.text?.appending(" @" + login)
}
像那样


希望有帮助

如果有帮助,你需要接受答案,让别人更快地找到答案。