我嘗試修改我的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!!!!
}
感謝您的幫助
首先,'USEREDIT = [[用戶的alloc] INIT]做文本字段值設置;'是錯誤的,並創建一個內存泄漏。只要刪除它。其次,你沒有向我們展示相關的代碼。我們從「self.user.servertitle」顯然包含您期望的字符串和'self.user.title'可能不會包含的字符串中扣除什麼?我們對這些對象一無所知,以及如何創建它們。 – 2010-01-26 16:10:35
對不起,這兩種情況下應該是user.title 我有以下參數在我看來: @synthesize user,userTitle; 和我的頭文件 @property(nonatomic,retain)IBOutlet UITextField * userTitle; 和 用戶*用戶; – phx 2010-01-26 16:35:42