reload cell data in table view with Swift

前端 未结 4 1343
不知归路
不知归路 2020-12-14 09:28

how is it possible to reload data for a cell in my table view? I want to do a request to my Server and the server responses JSON. At the moment I implemented the request and

相关标签:
4条回答
  • 2020-12-14 09:39

    you can get Array of visible Cell by using TableView Function tableView.visibleRows() or You Can Get IndexPath of Visible Rows By tableView.indexPathsForVisibleRows() ! and then you can reload table by tableView.reloadData() Function!

    look at following links

    link1

    you can read about UITableView Class Here

    0 讨论(0)
  • 2020-12-14 09:44

    To reload visible cells of tableview in Swift 3.0

    pTableView.beginUpdates()
    
    pTableView.reloadRows(at: pMessagesTableView.indexPathsForVisibleRows!, with: .none)
    
    pTableView.endUpdates()
    
    0 讨论(0)
  • 2020-12-14 09:46

    You can use self.tableView.reloadData() in order to reload your entire table or self.tableView.reloadRowsAtIndexPaths(paths, withRowAnimation: UITableViewRowAnimation.None) in order to reload a specific cell.

    You can read more about the UITableView class here

    0 讨论(0)
  • 2020-12-14 09:49

    Try this...

    Swift 2.0

    dispatch_async(dispatch_get_main_queue(), { () -> Void in
       self.tableView.reloadData()
    })
    

    Swift 3.0

    DispatchQueue.main.async {
        self.tableview.reloadData()
    }
    
    0 讨论(0)
提交回复
热议问题