Refresh certain row of UITableView based on Int in Swift

前端 未结 11 667
别跟我提以往
别跟我提以往 2020-12-23 02:50

I am a beginning developer in Swift, and I am creating a basic app that includes a UITableView. I want to refresh a certain row of the table using:

self.tabl         


        
11条回答
  •  既然无缘
    2020-12-23 03:34

        extension UITableView {
            /// Reloads a table view without losing track of what was selected.
            func reloadDataSavingSelections() {
                let selectedRows = indexPathsForSelectedRows
    
                reloadData()
    
                if let selectedRow = selectedRows {
                    for indexPath in selectedRow {
                        selectRow(at: indexPath, animated: false, scrollPosition: .none)
                    }
                }
            }
        }
    
    tableView.reloadDataSavingSelections()
    

提交回复
热议问题