在我第一次加载时,一切都很棒。这是我的NSlog
2013-03-07 09:15:57.289 SAMPLE[10566:207] -->Starting viewDidLoad
2013-03-07 09:15:57.775 SAMPLE[10566:207] -->Starting viewDidAppear
2013-03-07 09:15:58.518 SAMPLE[10566:207] all done!
2013-03-07 09:15:58.518 SAMPLE[10566:207] stories array has 4 items
2013-03-07 09:15:58.527 SAMPLE[10566:207] -->Starting CellForRowAtIndex
但是,当我单击导航中的后退按钮并再次单击视图时,它会一直挂起,直到填充单元格。见下面的NSlog
2013-03-07 09:16:06.252 SAMPLE[10566:207] -->Starting viewDidLoad
2013-03-07 09:16:06.309 SAMPLE[10566:207] -->Starting CellForRowAtIndex
2013-03-07 09:16:07.019 SAMPLE[10566:207] -->Starting CellForRowAtIndex
2013-03-07 09:16:07.679 SAMPLE[10566:207] -->Starting CellForRowAtIndex
2013-03-07 09:16:08.198 SAMPLE[10566:207] -->Starting CellForRowAtIndex
2013-03-07 09:16:09.242 SAMPLE[10566:207] -->Starting viewDidAppear
我的viewDidAppear在此有以下内容。
- (void)viewDidAppear:(BOOL)animated {
NSLog(@"-->Starting viewDidAppear");
[super viewDidAppear:animated];
if ([[xmlParser branch] count] == 0) {
[self loadDatafromServer]; // Goes and runs my XML Parser and fill the array.
}
[self loadBranchs]; // This just loads my annotations for my map
[self.tableView reloadData];
}
这里有任何想法。正如我所说,她第一次加载完美,但如果用户回来并进来,它首先填充单元格导致延迟。我希望它打开视图然后填充。指示器将显示它们的载荷。
答案 0 :(得分:2)
不要在viewDidAppear中实现该任务,因为此方法在呈现视图之前执行与之关联的其他任务。所以延迟。更好地在viewWillAppear方法中实现它。
- (void)viewWillAppear:(BOOL)animated {
[super viewWillDidAppear:animated];
if ([[xmlParser branch] count] == 0) {
[self loadDatafromServer]; // Goes and runs my XML Parser and fill the array.
}
[self loadBranchs]; // This just loads my annotations for my map
[self.tableView reloadData];
}
希望它可以帮助你:)