BANANENMANNFRAU BANANENMANNFRAU - 3 months ago 14
iOS Question

iOS swift reload table view cell from a detailed views

I want to reload a

UITableViewCell
that I edited in a detailed view. I do not want to reload the whole
UITableView
.

I already passed the
NSIndexPath
to my detailed view. How can I access the
UITableView
s
reloadRowsAtIndexPath
s from my detailed view? Preferably in
viewWillDisappear
.

Answer

With help of rdelmar I have found the answer for my problem.

Here is what I added in my TableViewController

 var oldIndexPath: NSIndexPath? = nil

  override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        if let indexPath = self.tableView.indexPathForSelectedRow(){
            oldIndexPath = indexPath
        }
  }

  override func viewWillAppear(animated: Bool) {

        if let indexPath = oldIndexPath as NSIndexPath! {
            self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None)
        }

   }
Comments