我有麻煩負載找出如何做到這一點,創建向下鑽取詳細的UITableView
我想在UITableDetailView(向下鑽取樣式)與在每個項目顯示此不同的細胞。我讀過的所有東西都顯示瞭如何在細節上加載單個圖像,而不是顯示爲UITableView。字典是否必須有「孩子」才能正確加載?這裏是第一個視圖從JSON rowsArray創建* dict的代碼。
我想我要找的是放入FollowingDetailViewController.m以查看* dict內容的其餘部分,因此當選擇一行時,它會加載* dict的其餘部分。
我有rowsArray回來如下:
'{loginName = Johnson;
memberid = 39;
name = Kris;
年齡=;},等等,等等...
感謝,
//設置表&細胞
- (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];
}
謝謝,我傾向於你的方法,在我得到表格加載後,我將把數組保存到一個.plist中,以便在啓動時持久化並重新加載。檢查數據是否可用。我可以保存並使用JSON對象模型,對嗎? – 2010-06-11 12:57:57
我只是將模型對象作爲爲您的目的而量身定製的通用nsObject。你可以堅持plist,sqllite,核心數據等。 – Nick 2010-06-11 16:02:24