2010-01-26 22 views
1

我嘗試修改我的didSelectRowAtIndexPath方法以使用我的AddView也可以進行編輯(僅適用於填充文本框)。但它不工作!我剛進入編輯模式,檢查(self.editing),並做一些事情,如:didSelectRowAtIndexPath在編輯模式下更新數據

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]這樣的用戶對象,但這也不起作用,所以我用init嘗試了它。

我setEditUser方法看起來像(附圖)

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

}

感謝您的幫助

+0

首先,'USEREDIT = [[用戶的alloc] INIT]做文本字段值設置;'是錯誤的,並創建一個內存泄漏。只要刪除它。其次,你沒有向我們展示相關的代碼。我們從「self.user.servertitle」顯然包含您期望的字符串和'self.user.title'可能不會包含的字符串中扣除什麼?我們對這些對象一無所知,以及如何創建它們。 – 2010-01-26 16:10:35

+0

對不起,這兩種情況下應該是user.title 我有以下參數在我看來: @synthesize user,userTitle; 和我的頭文件 @property(nonatomic,retain)IBOutlet UITextField * userTitle; 和 用戶*用戶; – phx 2010-01-26 16:35:42

回答

0

它的工作原理,如果我在

- (void)viewDidAppear:(BOOL)animated{ 
self.userTitle.text = self.user.title;} 
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文檔上。

+0

謝謝,即時能夠做編輯:)但即時通訊不能發送數據到我的看法(textfields不顯示的值,NSLog的) – phx 2010-01-26 16:43:44

相關問題