0

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

4

1 回答 1

1

您需要保留两个 tableViews 的引用,两个单独的 dataSource 数组。并且当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];
    }
}
于 2013-05-02T07:29:40.013 回答