尝试在默认方法之外访问 UITableView 的自定义单元格来更新数据,它崩溃了下面是我的代码:
let cell = tblAddPlayer.cellForRow(at: indexPosition) as! DropDownCell. // Crashing here..
cell.txtFieldSearchCity.text = city
tblAddPlayer.reloadRows(at: [indexPosition], with: .none)
我只需要根据下一个视图控制器的选择更新一个单元格的数据。因此,将数据传递回之前的 viewController 并需要在 UITableViewCell 中更新该值。因此尝试访问自定义单元格但遇到崩溃和错误。请指导这里有什么问题。
崩溃和错误:
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /PlayerViewController.swift, line 111