didSelectRowAtIndexPath在编辑模式下更新数据

时间:2010-01-26 15:55:08

标签: iphone objective-c

我尝试修改didSelectRowAtIndexPath方法以使用我的AddView进行编辑(仅限填充的文本字段)。但它不起作用!我只是进入编辑模式,检查是否(se​​lf.editing)并执行以下操作:

   if (self.editing) {
        AddViewController *viewController = [[AddViewController alloc] 
                                             initWithNibName:@"AddView" bundle:[NSBundle mainBundle]];
    //get selected Object  
    User *userEdit = [[User alloc] init];
    userEdit = [self.users objectAtIndex:indexPath.row];
    viewController.user = userEdit;
    [viewController setEditUser];

    [self.navigationController pushViewController:viewController animated:YES];
    [viewController release];
    //deselect Row after navigate back
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

我做错了什么?我也尝试发送像[viewController setEditUser:editUser]这样的User对象,但是这也没有用,所以我用init尝试了。

我的setEditUser方法看起来像(在视图中)

- (void)setEditUser{
self.userTitle.text = self.user.title; //this is not working!!! ?????
NSLog(@"blub %@", self.user.title); //this is working!!!!

}

感谢您的帮助

2 个答案:

答案 0 :(得分:1)

不完全确定你在问什么,但也许你应该看看

@property(nonatomic) BOOL allowsSelectionDuringEditing

Discussion

If the value of this property is YES , users can select rows during editing. The default value is NO. If you want to restrict selection of cells regardless of mode, use allowsSelection.

在UITableView文档中。

答案 1 :(得分:0)

如果我在

进行文本字段值设置,它会起作用
- (void)viewDidAppear:(BOOL)animated{
self.userTitle.text = self.user.title;}