gpt4 book ai didi

iphone - 如何制作两个像 2 行 uipickerview 一样工作的自定义表格 View

转载 作者:行者123 更新时间:2023-11-29 03:57:31 25 4
gpt4 key购买 nike

我创建了一个 uiscrollview 并添加了一个 uitableview 作为 subview 。我使用此类创建两个 ScrollView ,每个 ScrollView 都在其中添加了一个表格 View 。我希望这 2 个表格 View 像 uipickerview 一样工作,其中有 2 行。当我单击左侧的 uitableviewcell 时,另一个表格 View 应该重新加载其数据以匹配选择。就像 uipickerview 一样,当单击第 0 行中的某个项目时,第 1 行会更新其数据。我想在tableview中实现这个功能,唯一的区别是我点击tableview中的单元格,而不是像uipickerview那样滚动项目。

最佳答案

您需要保留两个 TableView 、两个单独的数据源数组的引用。当选择 mainTableView 时,形成第二个 tableView 的 dataSource 并重新加载它。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView.tag == 1) //Main TableView
{
//Form the dataSource of the second tableView
//You need to have a logic to form this array
//from the selected indexPath of main tableView
self.secondDataSourceArray = ...
[self.secondTableView reloadData];
}
}

关于iphone - 如何制作两个像 2 行 uipickerview 一样工作的自定义表格 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16332449/

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