如何在一个 xib 和三个连接中添加三个 table

How to add Three table in one xib and also three connection

我想拿三个 table 并在同一个 xib.Can 上做三个不同的连接 任何人都可以帮助我。任何演示。

是的,您可以添加 .只需设置不同的 Tag 并根据 tagValue 处理数据。

并连接 datasourcedelegate 所有表。

创建所有表的 IBOutlet 并设置所有 3 个表的数据源和委托。

现在在所有数据源和委托方法中只需像下面这样检查

  if (tableView == self.tableview1) {
      //Do task for that table1
  }
  else if (tableView == self.tableview2) {
      //Do task for that table2
  }
  else {
      //Do task for that table3
  }

希望这会有所帮助。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView == self.tableView1) { return 5; } else if (tableView == self.tableView2) { return 10; } else if (tableView == self.tableView3) { return 20; } else { return 0; } }

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell; if (tableView == self.tableView1) { cell = [tableView dequeueReusableCellWithIdentifier:@"Cell1" forIndexPath:indexPath]; } else if (tableView == self.tableView2) { cell = [tableView dequeueReusableCellWithIdentifier:@"Cell2" forIndexPath:indexPath]; } else { cell = [tableView dequeueReusableCellWithIdentifier:@"Cell3" forIndexPath:indexPath]; } return cell; }