I have a table view that displays contact information. I have another view that acts as a "contact pad." Basically it has either empty or text filled rows. I want it to have empty rows (or default state) when the user taps on a button on the tableview and I want it to pre-populate text when the user taps a row on the tableview. My methods for writing/reading to the datasource work fine, but once the "contact pad" view is brought up; it saves its state.
For example, if I open the "contact pad" view with the button then it shows the proper default state. Then if I open the "contact pad" view via tap开发者_开发问答ping on a row it will display the correct text, but if I go try to open it again via the button then it will not re-show the default state and instead will show the text from before.
How do I reset a view once it has been closed? Do I call dealloc() before [self removeFromSuperview]?
In the viewWillAppear
method, just do a
[self.tableView reloadData];
This method will be called every time there is a navigation or each time the view is opened.
Just remember that after you add your view as a subview its retain count goes up by 1. So if you remove it from the superview it comes down by 1. You should release your subview after you add it to another view. This way when you call removeFromSuperview it counts get down by one and gets freed totally.
精彩评论