2013-07-24 75 views
0

首先刷新數據,我有一個滑動應用中,有我有一個的tableview。 通過在主菜單輕敲細胞「CellInMainMenu」,應用程序打開的tableview「TV1」通過推入,並將細胞在此的tableview(「TV1」)填充由陣列數據。當我今天的tableview(「TV1」)到另一邊,並tapps再次細胞「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; 

} 

(所有機應用工作正常,我只是想知道如何使只有一個負載但不是每次)

回答

0

的問題是不是你的表視圖代碼,但你如何推它。如果你調用一個segue,它總是會創建一個新的。

相反,你只能推它的第一次,保持對它的引用,然後根據你的選擇菜單的更新。一些自定義代理@protocol可能是最好的模式。

+0

非常感謝您! =) –