Multiple Table View Delegate/datasource

Discussion in 'iOS Programming' started by beesbane, Nov 8, 2010.

  1. beesbane macrumors newbie

    Oct 16, 2010
    I have a segmented controller that switches between 2 tableviews. One is hidden, while the other is visible. Is it possible to set these up to load different sets of information within a single view?

    My purpose is actually that one is set up with one particular view cell, and the other with another. But the information is the same.

  2. Comrade Yeti macrumors newbie

    Nov 3, 2010
    All your UITableView methods will pass in the table view that is asking for data. Based on which table view is passed in, you can do what you need to.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
      if(tableView == table1) {
        // Do stuff for table1 here
      } else if (tableView == table2) {
        // Do stuff for table2 here
    Just make sure table1 and table2 are declared with IBOutlet and connected in Interface Builder to your controller. Return a different cell for each Table.
  3. Sykte macrumors regular

    Aug 26, 2010
    If the only difference between UITableView1 and UITableView2 is the cell layout you can handle this with the cell identification.

Share This Page