2012-04-10 64 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

相关问题