Iphone 将此JSON数组中的其他字符串转换为UITableView详细信息
我有一个NSURL请求,它返回一个“name”和“phone”数组,等等。。。“name”键在主表上显示得很好,但在选择行时,我很难弄清楚如何使数组的其余部分显示在细节表上。(我让DetailerTableViewController接受该视图)。任何帮助都将不胜感激 谢谢Iphone 将此JSON数组中的其他字符串转换为UITableView详细信息,iphone,arrays,uitableview,Iphone,Arrays,Uitableview,我有一个NSURL请求,它返回一个“name”和“phone”数组,等等。。。“name”键在主表上显示得很好,但在选择行时,我很难弄清楚如何使数组的其余部分显示在细节表上。(我让DetailerTableViewController接受该视图)。任何帮助都将不胜感激 谢谢 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [rowsArray
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [rowsArray count];
NSLog(@"row count: %@",[rowsArray count]);
}
- (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)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0/255.0 green:207.0/255.0 blue:255.0/255.0 alpha:1.0];
self.title = NSLocalizedString(@"Master", @"Master");
NSURL *url = [NSURL URLWithString:@"http://10.0.1.8/~imac/iphone/jsontest.php"];
NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url];
NSLog(jsonreturn); // Look at the console and you can see what the results are
NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding];
NSError *error = nil;
// In "real" code you should surround this with try and catch
NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];
if (dict)
{
rowsArray = [dict objectForKey:@"member"];
[rowsArray retain];
}
NSLog(@"Array: %@",rowsArray);
NSLog(@"count is: %i", [self.rowsArray count]);
[jsonreturn release];
}
您需要实施:
-(void)tableView:(UITableView*)aTableView didSelectRowAtIndexPath:(nsindepath*)indepath
处理行选择并为详细视图推送视图控制器。谢谢-我有这个功能,它可以推送,但是结果页面只是“name”单元格。textlab.text=[dict objectForKey:@“name”];我想显示名称以及数组中的所有其他内容。您在这个方法中使用了什么?如果推送另一个表视图控制器,则需要将每一行设置为单独的数据行。或者您可以在自定义UIViewController子类中使用您填写的UILabels创建自己的视图。我确实推了另一个视图控制器,我遇到了这个问题,我必须有一个单独的视图控制器,因为该视图除了详细表外还有两个项目,我想我的问题应该是:如何为上表中的数组中的每个项设置单独的单元格?