views:

217

answers:

1

Hello -

My iPad app was rejected due to my use of a picker. The picker was used to control a table view. In my view, a picker was displaying a series of items and when one of those items was selected, it used that selection to populate a table with data. (hopefully that makes sense). Now I need to do this without the picker so I need to have the data that was in the picker be represented in a table view.

My question, is how do I have multiple tableViews in the same view?

is it as simple as having separate delegate methods for each tableview like this?

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView1
{

    return [xxx count];

}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView2
{

    return [yyy count];

}
A: 

The names of the delegate methods are fixed. So you can either

  1. Use two different delegate instances, or
  2. Identify the table within the method, e.g.

    -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        if (tableView.tag == 114)
          return [xxx count];
        else
          return [yyy count];
    }
    
KennyTM
with me being a noob, can you expand on "Use two different delegate instances "?
Brodie
@Brodie: For example, you create `@interface A` and `@interface B`, then assign `tableA.dataSource` to an instance of A, and `tableB.dataSource` to an instance of B.
KennyTM
great, understood, thanks!
Brodie