0

我想知道,如何将选定的联系人从一个 tableview 复制并显示到另一个 tablview。我在表格视图中列出了联系人。我可以选择多选联系人。当我点击完成(选择后)时,我需要将选定的联系人复制到另一个表格视图。有人可以指导我如何实现它。

示例示例或代码将非常有用。

提前致谢。

4

2 回答 2

2

您必须为您的 First tableview 提供数据源。所以你可以使用 DidSelectRowAtIndex方法,1)获取 indexpath.row 并将项目从指定 indexpath.row 的数据源复制到一个新数组(这将成为你的第二个 tableview 的数据源。

如下所示:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//customArray is datasource for this tableview
NSString *item=    [self.customArray objectAtIndex:indexPath.row];
//arr is datasource for second tableview
    [arr addObject:item];
}

希望能帮助到你。

于 2012-05-11T04:19:32.017 回答
0
lowerLblItem_Unit_Cost.text = [NSString stringWithFormat:@"%@", [delegate.addItem_UnitCost objectAtIndex:indexPath.row]];
    lowerLblItem_Unit_Cost.backgroundColor = [UIColor clearColor];

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//customArray is datasource for this tableview
NSString *item=    [self.customArray objectAtIndex:indexPath.row];
//arr is datasource for second tableview
    [arr addObject:item];

or // you can use your own label

lowerLblItem_Unit_Cost.text = [NSString stringWithFormat:@"%@", [delegate.addItem_UnitCost objectAtIndex:indexPath.row]];
    lowerLblItem_Unit_Cost.backgroundColor = [UIColor clearColor]; 

}
于 2012-05-11T07:49:21.417 回答