2012-04-10 65 views
0

基本上,我將項目添加到新視圖中的表格,如果用戶點擊保存,我希望視圖彈出,以及更新前的表格視圖以顯示新的添加。關於如何完成這項任務的任何想法?當用戶點擊導航視圖中的「保存」按鈕時,我希望重新加載表格視圖

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PersonTableViewCell"]; 

    if(!cell){ 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"PersonTableViewCell"]autorelease]; 
    } 
    p = [friendsArray objectAtIndex:[indexPath row]]; 

    [[cell textLabel] setText:[p description]]; 
    return cell; 
} 

回答

2

你可以嘗試先通過彈出當前視圖控制器:

[self.navigationController popViewControllerAnimated:YES]; 

然後在您的表視圖控制器的viewDidAppearviewWillAppear,叫

[self reloadData]; 

更新。

+0

問題是,當我這樣做時,它說我已將消息發送到解除分配的實例,我不知道如何解決該問題。 – Jerome 2012-04-10 16:38:40

+0

上一個表視圖控制器不應該被釋放。導航控制器也不應該。如果他們這樣做了,那麼你在代碼的其他部分沒有正確管理它們。 – 2012-04-10 16:41:59

+0

我確定它不是表視圖控制器,而是一個導致錯誤的對象'p': – Jerome 2012-04-10 16:49:56

相關問題