我想在一个类中实现两个 Tableview。 我知道 objective-C 不支持方法重载,也知道如何使用相同方法使用两个 TableView 但如果参数类型不同怎么办?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView dismisWithIndexPath:indexPath];
}
- (void)tableView:(YALContextMenuTableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
最佳答案
您不能在同一个 View Controller 中为两个 TableView 使用两个单独的委托(delegate)方法。您可以更好地为 TableView 设置标签和名称,而不是使用两个不同的 TableView 委托(delegate)方法。
第一个 TableView 名称
if([tableView isEqual:YourFirstTableViewName]) {
......//Your coding part
}
else if([tableView isEqual:YourSecondTableViewName]) {
......//Your coding part
}
else {
......//Your coding part
}
第二次使用table view的标签
if(tableView.tag == 0) //Set tag whatever you want for first table view
{
......//Your coding part
}
else if(tableView.tag == 1) //Set tag whatever you want for second table view
{
......//Your coding part
}
关于ios - 如何在一个类中使用不同的委托(delegate)和数据源方法实现两个 Tableview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49097643/