简体   繁体   中英

iPhone, how do I determine when a child screen passes back to a UITableView and how do I update that row?

I asked a question the other day about how rows are added to a UITableView after the table is shown and I was told that the datasource should be updated and insertIndexPaths:withRowAnimation should be called.

My UITable view contains rows of data, when the row is clicked another screen is shown which allows the user to edit the data, once they click done for that screen I want the data in the row to be updated too. I understand calling reloadData is not the right approach here.

Going back a step or two, how does the UITableView view know when it is returned to be the edit screen ? and which event do handle datasource / row updates?

I'm also going to want to add new row (in and add view) in a similar manner, which event do i use then ?

You can keep track with -viewWillAppear:animated: . This works with any view controller. Reload your data in there. So the process is:

  • Edit your data
  • Save the new data in your model (where the table view is getting its data)
  • Pop the detail view controller
  • In the table view controller, have a viewWillAppear:animated: method where you reload your table (using reloadData )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM