【发布时间】:2013-07-25 00:42:55
【问题描述】:
首先,我有一个幻灯片应用程序,还有一个表格视图。 通过点击主菜单中的单元格“CellInMainMenu”,应用程序通过推送打开 tableview“TV1”,并且此 tableview(“TV1”) 中的单元格通过数组填充数据。当我将这个 tableview("TV1") 滑动到一边,然后再次点击单元格“CellInMainMenu”时,应用程序再次打开 tableview("TV1"),但是! Tableview("TV1") 再次开始用信息填充单元格!如何让应用在启动应用时一次性加载所有数据?
(我真的很抱歉我的英语不是我的语言)
有人可以帮帮我吗?
“TV1”中的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
daoDS = [[SampleDataDAO alloc] init];
self.ds = daoDS.PopulateDataSource;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TV1CellId";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
SampleData *sample = [self.ds objectAtIndex:indexPath.row];
cell.textLabel.text = sample.HeroesName;
cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.font = [UIFont fontWithName:@"Trajan-Regular" size:18.0f];
return cell;
}
(所有应用程序都可以正常工作,我只想知道如何只加载一次,但不是每次都加载)
【问题讨论】:
标签: ios uitableview viewdidload