2009-10-21 50 views
0

我正在使用rss feed.first時間,表視圖沒有rows.if我按下按鈕,會出現values.if我再次按下,表視圖有以前values.after收到它的數據它消失,新的數據會到那裏但是當我按下按鈕時,不能有以前的值。我想
刪除它。我該怎麼辦?任何幫助?如何將UITableviewcell或UITableview設置爲空?

+2

您提出21個問題,並接受0個。你應該回去接受一些答案。 – 2009-10-21 18:56:43

回答

0

當你需要更新你的UITableView調用[tableView reloadData]方法的內容。因此,如果到那時您已經清除了您的數據源中的以前的數據,那麼該表必須爲空。

+0

不,我試過了。假設表中有一個url的值。如果點擊 BUTTON,它會傳遞相同的url,那時候沒有更新,previoue的值在那裏...... – 2009-10-21 07:45:39

+0

很難說沒有看到你的代碼......如果以前的值仍然在表中,這意味着你還沒有清除你的數據源 – Vladimir 2009-10-21 08:29:58

0

UITableView通過數據源工作。我會假設你已經跟着蘋果建立的tableview看起來應該像這樣的方式:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 
{ 
    static NSString *identifier = @"identifier"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; 

    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease]; 
    } 

    cell.textLabel.text = [_tableViewData objectAtIndex:[indexPath row]]; 

    return cell; 
} 

在這個例子中的UITableView中的數據存儲在陣列tableViewData英寸這是初始化,如:

_tableViewData = [[NSArray arrayWithObjects:@"cell 1", @"cell 2", @"cell 3", @"cell 4", nil] retain]; 

所以,當你想更新的tableview的值,以新的東西,你需要改變tableViewData數組的值,並調用reloadData在表視圖。

_tableViewData = [[NSArray arrayWithObjects:@"new cell 1" , @"new cell 2", @"new cell 3", @"new cell 4", nil] retain]; 
[_tableView reloadData]; 
相關問題