Я создал tableView с панелью поиска. Когда я выбираю, например, первую ячейку отфильтрованного tableView, я получаю другой ViewController. Когда я нажимаю кнопку BackButton, я попадаю в TableViewController, но первая ячейка перезаписывается отфильтрованной ячейкой. Кто-нибудь знает, как я могу перезагрузить свой tableView или отменить выбор строки?
extension DictionaryViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if searching {
return searchCountry.count
} else {
return countrynameArr.count
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
if searching {
cell.textLabel?.text = searchCountry[indexPath.item]
return cell
} else {
cell.textLabel?.text = countrynameArr[indexPath.item]
print(countrynameArr[indexPath.item])
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// tblView.deselectRow(at: indexPath, animated: true)
myIndex = indexPath.item
let cell = tableView.cellForRow(at: indexPath)
countrynameArr[indexPath.row] = cell!.textLabel!.text!
print(countrynameArr[indexPath.row])
if shouldPerformSegue(withIdentifier: "segue0", sender: cell){
self.performSegue(withIdentifier: "segue0", sender: cell)
}
}