У меня есть простая таблица на моем представлении. В другом представлении есть массив с некоторыми значениями. Когда я вернусь, я хочу перезагрузить таблицу новыми значениями, но не работает.Обновить UITableview после назад
Мой класс:
let textCellIdentifier = "cell"
var menu:[[String]] = [[]]
var buscaEmp:BuscadorEmpresa = BuscadorEmpresa()
@IBOutlet weak var tablaVista: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
recuperaEmpresas()
tablaVista.delegate = self
tablaVista.dataSource = self
}
func recuperaEmpresas(){
menu = buscaEmp.getEmpresas()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return menu.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(textCellIdentifier, forIndexPath: indexPath) as! CustomTableViewCell
let row = indexPath.row
cell.nombreEmp.text = menu[row][0]
return cell
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
recuperaEmpresas()
tablaVista.reloadData()
}
Я использую viewWillAppear
перезагрузить таблицу перед возобновлять вид.
Вы уверены, что хотите '[[]]' вместо из '[]'? –
Да, после этого на моем другом классе y в комплекте с JSon –
Наконец, это было плохо, у меня был missclick на моем «forKey». Спасибо –