arachide
arachide

Reputation: 8076

Is it possible to put two UITableview in a UIView

I have a project in which I need to put two UITableView on one UIView.

I know it needs to set <UITableViewDelegate,UITableViewDataSource> and can function below:

-(NSString *) tableView:(UITableView *) tableView
titleForHeaderInsection:(NSInteger)section


- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView 


- (NSInteger)tableView:(UITableView *)tableView 
 numberOfRowsInSection:(NSInteger)section


- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath 


-(NSIndexPath *)tableView:(UITableView *)tableView 
 willSelectRowAtIndexPath:(NSIndexPath *)indexPath


 - (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath

but I do not know if these can process two tableviews (different from 2 sections).

Upvotes: 0

Views: 1073

Answers (1)

Ben Zotto
Ben Zotto

Reputation: 71058

It looks like you're asking if one object (maybe a view controller?) can have two UITableViews both using it as their delegate. Yes, a view controller can be the delegate for multiple table views-- that's why all of those methods pass in a UITableView* as their first argument; it's for you to use to figure out which one is which. You should keep a couple instance variables (IBOutlets probably) in your view controller so you know which is which and you can act appropriately.

Cheers, Interdev.

Upvotes: 1

Related Questions