in Education by
trying to change method to update the data, because with reloadData have lag let oldIns = insertCounter insertCounter += Int(INSERT_MESSAGES) // +40 var indexPaths = [IndexPath]() for section in (oldIns.. Int { return min(insertCounter, Int(dbmessages.count)) } //--------------------------------------------------------------------------------------------------------------------------------------------- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 5 } //--------------------------------------------------------------------------------------------------------------------------------------------- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return RCMessages().sectionHeaderMargin } //--------------------------------------------------------------------------------------------------------------------------------------------- func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return RCMessages().sectionFooterMargin } //--------------------------------------------------------------------------------------------------------------------------------------------- func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) { view.tintColor = UIColor.clear } //--------------------------------------------------------------------------------------------------------------------------------------------- func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) { view.tintColor = UIColor.clear } //--------------------------------------------------------------------------------------------------------------------------------------------- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if (indexPath.row == 0) { return RCSectionHeaderCell.height(indexPath, messagesView: self) } if (indexPath.row == 1) { return RCBubbleHeaderCell.height(indexPath, messagesView: self) } if (indexPath.row == 2) { let rcmessage = self.rcmessage(indexPath) if (rcmessage.type == RC_TYPE_STATUS) { return RCStatusCell.height(indexPath, messagesView: self) } if (rcmessage.type == RC_TYPE_TEXT) { return RCTextMessageCell.height(indexPath, messagesView: self) } } if (indexPath.row == 3) { return RCBubbleFooterCell.height(indexPath, messagesView: self) } if (indexPath.row == 4) { return RCSectionFooterCell.height(indexPath, messagesView: self) } return 0 } //--------------------------------------------------------------------------------------------------------------------------------------------- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if (indexPath.row == 0) { let cell = tableView.dequeueReusableCell(withIdentifier: "RCSectionHeaderCell", for: indexPath) as! RCSectionHeaderCell cell.bindData(indexPath, messagesView: self) return cell } if (indexPath.row == 1) { let cell = tableView.dequeueReusableCell(withIdentifier: "RCBubbleHeaderCell", for: indexPath) as! RCBubbleHeaderCell cell.bindData(indexPath, messagesView: self) return cell } if (indexPath.row == 2) { let rcmessage = self.rcmessage(indexPath) if (rcmessage.type == RC_TYPE_STATUS) { let cell = tableView.dequeueReusableCell(withIdentifier: "RCStatusCell", for: indexPath) as! RCStatusCell cell.bindData(indexPath, messagesView: self) return cell } if (rcmessage.type == RC_TYPE_TEXT) { let cell = tableView.dequeueReusableCell(withIdentifier: "RCTextMessageCell", for: indexPath) as! RCTextMessageCell cell.bindData(indexPath, messagesView: self) let numSections = self.tableView.numberOfSections if numSections == 1 { updateTableContentInset() } return cell } } if (indexPath.row == 3) { let cell = tableView.dequeueReusableCell(withIdentifier: "RCBubbleFooterCell", for: indexPath) as! RCBubbleFooterCell cell.bindData(indexPath, messagesView: self) return cell } if (indexPath.row == 4) { let cell = tableView.dequeueReusableCell(withIdentifier: "RCSectionFooterCell", for: indexPath) as! RCSectionFooterCell cell.bindData(indexPath, messagesView: self) return cell } return UITableViewCell() } How can i correct insert new row in tableview? Before does like this insertCounter += Int(INSERT_MESSAGES) tableView.reloadData() JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
It's a pretty simple code line: tableView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .top) This will insert the new row at the top of the table view. Then you would reload the data. This should fix the problem.

Related questions

0 votes
    When you start the application, you should get a line from the Firestore documents and write to an array, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    Why does UIImageView remove from Array when I used removeFromSuperview() with Swift? // display UIImageView var ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I have a class which has 2 sets of getter & setters. 1 set is the traditional type. These work ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 30, 2022 in Education by JackTerrance
0 votes
    In my password reset function the user can put in whatever he/she wants. It does not even needs ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I've searched Apple's documentation, open source projects, and Google, and I cannot seem to find any ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    How to change Swift version from 5 to 4 in Xcode?...
asked Mar 9, 2021 in Technology by JackTerrance
0 votes
    Recently implemented trailingSwipeActionsConfigurationForRowAt , where after swiping from right to left showing two options ... , JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I'd like to use the arrow/enter keys to traverse the cells in TableView, however, if I ... .setAlignment(Pos.CENTER_RIGHT); textField.textProperty().addListener((ObservableValue...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I'm stuck at the point of parsing a JSON array of dicts (http://www.cjs-design.nl/json.php) ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    I've managed to read some values into a table view and display them in the Master View of a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I would like to send one request when I scroll the tableview up and another request when I scroll down ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I would like to send one request when I scroll the tableview up and another request when I scroll down ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I would like to send one request when I scroll the tableview up and another request when I scroll down ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I would like to send one request when I scroll the tableview up and another request when I scroll down ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I've custom UICollectionViewCell that contains UILabel and UIImage. I want to set the cell in circular ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
...