一个View Controller中的两个TableView [英] Two TableViews in one View Controller

查看:168
本文介绍了一个View Controller中的两个TableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个视图控制器中有一个按钮和两个 tableViewController 。所以,如果我按下该按钮,第一表视图控制器将出现,它将以行显示一些数据。如果我将在第一表视图控制器中选择任何行,则第二表视图控制器将出现,并且需要显示第一表视图控制器的所选行的相应数据。在这里,我们必须在一个视图控制器中一次使用相同的表视图委托方法2个表视图控制器。可以吗?

I have one button and two tableViewControllers in one view controller. So, if i will press that button 1st table view controller will appear and it will display some data in rows. If i will select any row in that 1st table view controller, the 2nd table view controller will appear and it will need to display the corresponding data of selected row of 1st table view controller. Here we have to use same table view delegate methods for 2 table view controllers at a time in one view controller. Is it possible?

推荐答案

是的。由于数据源和委托方法提供了对tableview的引用,您可以简单地检查它是否等于您拥有的第一个或第二个表。

Yes. Since the data source and delegate methods provide a reference to the tableview, you can simply check if it is equal to the first or the second table you have.

示例:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  if ([tableView isEqual:_firstTable]) {
    // Do something
  }

  else { // tableView == _secondTable
    // Do something else
  }
}

这篇关于一个View Controller中的两个TableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆