I would like to use and display two tables开发者_开发知识库 on a UI view. Please let me know how to do this. Any code same will also be appreciated.
Thanks, Sandeep
- Add 2 UITableViews to your view in IB and connect them to 2 different outlets in file owner (or simply assign different tag properties).
- Set delegate and data source for them (may be same view controller for both).
In delegate/data source methods you do the following:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (tableView == myFirstTable) // return value for 1st table if (tableView == mySecondTable) // return value for 2nd table return 0; }
or if you use tag approach:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
switch(tableView.tag){
case firstTag:
// return value for 1st table
case secondTag:
// return value for 2nd table
}
return 0;
}
精彩评论