我很难找到如何做到这一点,
我想在 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];
}