I write custom jabber client in iphone.
I use xmppframework as engine.
And I have UITableViewController with NSMutableArray for repesent contact list.
<
Edit:
After testing, it doesn't always work!,
the reason is the index may change !
so the correct way is
make new variable
var currentIndex : IndexPath?
and on didSelectRow
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
currentIndex = indexPath
}
then change the function to
func reloadTableView() {
let indexPaths = tableview.indexPathsForSelectedRows
if let currentIndex = self.currentIndex {
self.tableview.reloadRows(at: [currentIndex], with: .fade)
for path in indexPaths ?? [] {
tableview.selectRow(at: path, animated: false, scrollPosition: .none)
}}
}
==========
@marmor Answer worked
this is a Swift version of his code
Swift 4.2.3
func reloadTableView() {
let indexPaths = tableView.indexPathsForSelectedRows
tableView.reloadData()
for path in indexPaths ?? [] {
tableView.selectRow(at: path, animated: false, scrollPosition: .none)
}
}