gpt4 book ai didi

ios - Objective C - iOS 多 TableView

转载 作者:行者123 更新时间:2023-11-28 18:22:33 26 4
gpt4 key购买 nike

我正在尝试编写一个连接到我的网络服务并在表格 View 中显示数据的应用程序。我还有一个菜单的静态 TableView 。静态 TableView 有效(响应点击、显示选项等),但我很难让第二个 TableView 正常工作。每个窗口不超过 1 个 TableView 。我将添加大约 10 个 TableView 。

静态表格 View 代码:

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"dataSelect"; //Name of table view


UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}

tableData 是我要插入的数组。

最佳答案

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"dataSelect"; //Name of table view

if (tableView == tableview1) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
} else if (tableview == tableview2) {

// do actions related to tableview 2 here

} else {

// and so on
}

关于ios - Objective C - iOS 多 TableView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17380273/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com