【发布时间】:2010-06-10 19:10:57
【问题描述】:
我很难找到如何做到这一点,
我想在 UITableDetailView(Drill-Down 样式)中显示这个,每个项目都在不同的单元格中。我读过的所有内容都显示了如何在细节上加载单个图像,而不是显示为 UITableView。字典是否必须有“孩子”才能正确加载?这是从 JSON rowsArray 创建 *dict 的第一个视图的代码。
我猜我正在寻找什么是将下面的detailviewController中放入的内容,以查看其余的* dict内容,因此在选择行时,它会加载*的其余部分。
我的 rowsArray 如下所示:
'{ loginName = Johnson;
会员编号 = 39;
名字=克里斯;
age = ;} 等等等等……
谢谢,
// 设置表格和单元格
- (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];
}
【问题讨论】:
标签: iphone json uitableview nsdictionary detailsview