-1

NSDictionary によって取り込まれているテーブルビュー (マスター/詳細) があります。masterview にはすべてのキーのリストが表示されますが、detailview (これも可能です) に値を表示させたいと思います。たとえば、マスター テーブルのキー 1 には、詳細ビューに表示したいいくつかの値があります。

これは私のテーブルビューです

-

 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell==nil)
    {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }
    NSString *key = [myKeyArray objectAtIndex:indexPath.row];
    NSDictionary *myDictionary = [MyDictionaryArray objectForKey:key];

    cell.textLabel.text=key;

    cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;

    }
    return cell

    //this gives me a list of all keys which is fine
}


-(void)tableView:(UITableView *)tableview didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{
    TableViewController *dvc=[[TableViewController alloc] init];


    //this is where I am stuck, I want the details to be pushed to the next tableview   

    [self.navigationController pushViewController:dvc animated:YES ];

}
4

1 に答える 1

1

詳細ビュー コントローラーをナビゲーション スタックにプッシュする前に、現在選択されている行の辞書を渡す必要があります。

NSString *key = [myKeyArray objectAtIndex:indexPath.row];
NSDictionary *myDictionary = [MyDictionaryArray objectForKey:key];

dvc.details = myDictionary;

details明らかに、カスタムTableViewControllerクラスでプロパティを宣言する必要があります。

于 2013-09-14T17:22:50.733 に答える