我使用uitableview获取NSURLconnection数据并试图显示它的tabController应用程序。我无法弄清楚这个问题。如果我用一个数组替换连接,我将存储所有的下钻工作,但更新不会,所以我认为tableView结束的事情是好的。但是:当源是NSURLConnection并获取新数据时重新加载tableview
如果我把[[self.tableview] reloadData];在 - (void)connectionDidFinishLoading:
这会导致在视图上的父行的循环。当您选择一行时,它会使用同一行“标题”重新填充,而不是它的子项。如果我删除[[self.tableview] reloadData]; tableDataSource3是空的,不会刷新URL数据,所以我需要它。我有NSLogs显示更新,所以我知道它正在更新。
如果我把[[self.tableview] reloadData];在ViewDidAppear中:
视图是空的,直到我移出表并返回(该应用程序是带有tableView的tabcontroller)。如果我在数据库中添加一行并通过NSURL连接进行更新,tableView会保持原样,但是如果我选择一行,那么更新后的新数据会出现在推送表中。
如果我把[[self.tableview] reloadData];在ViewWillAppear中:
视图是空的,直到我移出表并返回。但是,推入的子视图是空的。
任何想法?
这里是NSURLConnection的甲基
-(void) connectionDidFinishLoading:(NSURLConnection *)conn3 {
~ JSON STUFF~
NSArray *test = [json objectForKey:@"Rows"];
tableDataSource3 = [[NSArray alloc] initWithArray:test];
[json release];
[conn3 release];
self.receivedData =nil;
[[self tableview] reloadData];
}
这里到底是选择方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//Get the dictionary of the selected data source.
NSDictionary *dictionary = [self.tableDataSource3 objectAtIndex:indexPath.row];
//Get the children of the present item.
NSArray *Children = [dictionary objectForKey:@"Children"];
if([Children count] == 0) {
ItemDetailViewController *dvController = [[ItemDetailViewController alloc] initWithNibName:@"ItemDetailView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
}
else {
//Prepare to tableview.
ThirdTab *rvController = [[ThirdTab alloc] initWithNibName:@"SecondView" bundle:[NSBundle mainBundle]];
rvController.CurrentLevel3 += 1;
rvController.CurrentTitle3 = [dictionary objectForKey:@"Title"];
[self.navigationController pushViewController:rvController animated:YES];
rvController.tableDataSource3 = Children;
[rvController release];
}
}
@乔丹是在NSURL开始在viewDidLoad中 – 2010-10-23 04:32:20
@乔丹,我在connectionDidFinishLoading年底拿到了reloadData只有一次。添加自我是一个好主意,但我有同样的结果。 thx – 2010-10-23 04:44:27
我有一种感觉,整个didselectRowatIndexPath不正确的reloadData调用。我发布了一个新问题。 – 2010-10-27 17:22:32