Reload data of a table view from a child controller and another controlle

Discussion in 'iOS Programming' started by dunadan, May 31, 2009.

  1. dunadan macrumors newbie

    Joined:
    May 31, 2009
    #1
    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.
     
  2. CocoaPuffs macrumors 68010

    Joined:
    Aug 23, 2008
    #2
    If the tableview belongs to a subclass of UITableViewController, then you can simply reference the view controller's pointer and tell its tableView to reloadData. Or you can still do it by making ivar of the tableView and call it by referencing its pointer.
     
  3. dunadan thread starter macrumors newbie

    Joined:
    May 31, 2009
    #3
    Solved

    I solved it using viewWillAppear:(BOOL)animated and [self.tableView reloadData] inside that function, in the controller of the tableView.

    The thing is that now 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.

    EDIT: Solved using [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
     

Share This Page