views:

9521

answers:

3

Hi,

I'm implementing a notes manager application which has a tableView in a tabBar where the main information of its notes is displayed. When accessing to one note, you can edit its properties. In one button of the tabBar you can choose the way the notes are displayed in the tableView.

The problem I have is that I don't know how to reload the data from a child controller or from the other controller of the tabBar, either. I don't know how to refer to tableView from them so I can use reloadData to update the information of the TableView from them.

I'm quite new in iPhone development... any help will be really appreciated.

Thanks.

+1  A: 

the MVC pattern will help here,

as long as you keep updating your model with the information that is needed and your controllers are updating from that modal. As you flick back between the views you end up automatically updating the views.

that way you can call your reload data methods and they will get updated.

[tableviewController.tableview reloadData];

is how you access the reload data message.

Bluephlame
Thanks,I know about reloadData and I can use it in the file where the tableView methods are, but I don't know how to access to the tableViewController in the child controllers or other controllers in the tabBar.
+2  A: 

Put your table updating code in viewWillAppear: in stead of viewDidLoad - that way each time you go back to your parent controller from the child controller, the data get reloaded.

QAD
Thanks, but viewWillAppear function is not being called in my code... do you know why could this happen? Could I just do a [self.tableView reloaData] inside that function to solve my problem?
Yeah, it should help.Remember that viewWillAppear is defined as- (void)viewWillAppear:(BOOL)animatedNot just- (void)viewWillAppear
QAD
It works, thank you very much. The only thing that is wrong now is that when I come back from the child controllers, the row remains selected unless I select another one. It remains selected even if I click the disclosure button of another row and I come back to the table view. It's weird... any idea about how to solve this?, thanks.
Use [tableView deselectRowAtIndexPath:indexPath animated:YES];
QAD
Great, thanks QAD.
A: 

Hey thanks QAD & Zifre... Your post and answer helped me a lot. Was stuck with the same problem for a very long time....