2012-08-14 67 views
1

下創建了一個文本框是我寫我怎麼火textFieldDidEndEditing功能編程

UITextField *category =[[UITextField alloc] initWithFrame:CGRectMake(10, 90, subView.frame.size.width-15, 30)]; 
category.backgroundColor=[UIColor whiteColor]; 
category.placeholder = @"Category, Description, Model (optional)"; 
category.returnKeyType = UIReturnKeyNext; 
// [category addTarget:self action:@selector(textFeild) forControlEvents:<#(UIControlEvents)#>] 

應該採取什麼說法是,這樣我可以添加textFieldDidEndEditing控制事件的代碼?

回答

1

UITextField自我

category.delegate = self; 

委託請確保您的類創建UITextField實現UITextFieldDelegate

+0

不工作,我沒有什麼是錯的。這甚至不會觸發鍵盤將隱藏通知 – LostPuppy 2012-08-14 18:43:29

+0

嘗試將returnkeytype更改爲完成或返回或默認 – tGilani 2012-08-15 06:12:05