Reputation: 652
In my app i have used table view for displaying the list of videos available and some details about that. i have used UIWebview
to play the video when the user selects it, now i want to display the comments of the video in that webView
below the player, what is the best way to do it, i know UITableView
is good, but i have already used tableView
delegate and customized it, now how can i use different UITableview
delegate in the same file. Is there any better way to display comments other than tableView
.
Upvotes: 0
Views: 84
Reputation: 1024
We can use two tableviews
on the same viewcontroller
and you can differentiate between two by assigning them tags
…or you can also check them by comparing their memory
addresses.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if(tableView.tag==1){
return [dataArray count];
}else{
return [dataArray1 count];
} }
or
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if(tableView==tableView1){
return [dataArray count];
}else{
return [dataArray1 count];
} }
Upvotes: 3
Reputation: 47099
Define your another UITableView
in .h file also and create and give delegate and datasource as same like tableView1.
And just put condition when you want to use tableView2 in delegate and datasource method such like
if(self.tableView2 == tableView)
{
// write code for tableView-2
}
else
{
// write code for tableView-1
}
Upvotes: 0
Reputation: 7850
Check tableView
parameter in your delegate/data source methods. Example:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == _tableview1)
{
// do one thing
}
else if (tableView == _tableview2)
{
// do other thing
}
}
Upvotes: 3