Two TableViews in one View Controller [duplicate]

ε祈祈猫儿з 提交于 2019-12-30 18:29:07

问题


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?


回答1:


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.

Example:

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

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


来源:https://stackoverflow.com/questions/21836017/two-tableviews-in-one-view-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!