0

我很难找到如何做到这一点,

我想在 UITableDetailView(Drill-Down 样式)中显示这个,每个项目都在不同的单元格中。我读过的所有内容都显示了如何在细节上加载单个图像,而不是显示为 UITableView。字典是否必须有“孩子”才能正确加载?这是从 JSON rowsArray 创建 *dict 的第一个视图的代码。

我想我正在寻找的是在FollowingDetailViewController.m 中放置什么以查看*dict 的其余内容,因此在选择一行时,它会加载*dict 的其余部分。

我的 rowsArray 如下所示:

'{ 登录名 = 约翰逊;

成员ID = 39;

名字=克里斯;

年龄 = ;} 等等等等...

谢谢,

// 设置表格和单元格

  - (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] autorelease];
}
    NSDictionary *dict = [rowsArray objectAtIndex: indexPath.row];

    cell.textLabel.text = [dict objectForKey:@"name"];
    cell.detailTextLabel.text = [dict objectForKey:@"loginName"];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;   
    return cell;
}

- (void)viewDidAppear:(BOOL)animated {
      [super viewDidAppear:animated];



- (void)viewDidLoad {
    [super viewDidLoad];

//GET JSON FROM WEBSERVICES:
    NSURL *url = [NSURL URLWithString:@"http://10.0.1.8/~imac/iphone/jsontest.php"];
    NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url];

    NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding];
NSError *error = nil;

    NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];
    if (dict)
    {
        rowsArray = [dict objectForKey:@"member"];
        [rowsArray retain];
    }


[jsonreturn release];

}

//GO  TO DETAIL VIEW:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    FollowingDetailViewController *aFollowDetail = [[FollowingDetailViewController alloc] initWithNibName:@"FollowingDetailView" bundle:nil];
    [self.navigationController pushViewController:aFollowDetail animated:YES];
}
4

1 回答 1

0

不要使用阻塞调用来检索 JSON。如果您的网络速度很慢,您的应用程序将挂起。您应该使用异步方法来检索数据。

查看将 JSON 内容加载到模型对象中。然后使用一系列模型为您的 tableview 提供动力。DidSelectRowAtIndexPath 然后可以通过自定义初始化程序或通过在分配/初始化后设置属性将模型对象的实例传递到您的详细信息视图中。你的问题很难解析,所以我不确定我是否在解决你想要的问题。查看开发人员网站上的大量表视图 UI 层次结构示例。

于 2010-06-11T06:03:04.360 回答