I have a list of accounts in a TableView
. After I press a button, an item is deleted. So far so good.
How to refresh tableView after deletion? Please find the below screenshot for more information.
TableView is in another ViewController, the button to delete is in a ViewControllerCell
class cellAccount: UITableViewCell {
@IBOutlet weak var imgAccount: UIImageView!
@IBOutlet weak var lblNomeAccout: UILabel!
@IBOutlet weak var btnDeletar: UIButton!
@IBAction func btnDeletar(sender: AnyObject) {
print(btnDeletar.titleLabel?.text)
if (bdAccount.indexOf((btnDeletar.titleLabel?.text)!) != nil) {
print(bdAccount.indexOf((btnDeletar.titleLabel?.text)!))
bdAccount.removeAtIndex(bdAccount.indexOf((btnDeletar.titleLabel?.text)!)!)
bdAccount.sortInPlace()
self.tableView.reloadData() // How to Reload???
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}