0

First, i have a slide application, there i have a tableview. By tapping a cell "CellInMainMenu" in the main menu, application opens tableview "TV1" by push, and cells in this tableview("TV1") fill with data by an array. When i slide this tableview("TV1") to side, and tapps again on a cell "CellInMainMenu", application opens again tableview("TV1"), but! Tableview("TV1") starts AGAIN to fill cells with information! How to make application load all data by once at starting application?

(I'm really sorry for my English, because it's not my language)

Can somebody help me?

Code in "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;

}

(All appliction works fine, i just want to know how to make just one load but not every time)

4

1 回答 1

0

问题不在于您的表格视图代码,而在于您如何推送它。如果你调用一个 segue,它总是会创建一个新的。

相反,您只能在第一次推送它,保留对它的引用,然后根据您选择的菜单更新它。一些自定义委托@protocol可能是最好的模式。

于 2013-07-24T10:22:08.153 回答