我想拿三个表,并在同一个xib上做三个不同的连接。谁能帮我。任何演示。
创建所有表的 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
}
希望这会有所帮助。
是的,您可以添加 .只需将Tag
设置为不同并根据tagValue
处理数据即可。
并连接datasource
并delegate
所有表。
- (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;
}