2013-07-10 27 views
0

是否有可能以某種方式從UITextField中捕獲清除按鈕方法,然後爲它提供更多操作,如地圖上的清晰註釋等?如何捕捉UITextField中的清除按鈕

在哪個方法中,我需要使用清除按鈕捕獲附加信息?

感謝您的幫助,快速解答

+3

你有沒有試過把它加到你的['textFieldShouldClear'](http://developer.apple.com/library/ios/documentation/uikit/reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html#//apple_ref/occ/ UITextFieldDelegate委託協議的intfm/UITextFieldDelegate/textFieldShouldClear :)方法? – Rob

回答

2

你可以自己設置爲文本字段代表和執行textField:shouldChangeCharactersInRange:replacementString:。如果rangetextField.text的全部範圍並且替換string等於@""那麼它是明確的操作。

請注意,用戶手動選擇所有文本並在鍵盤上打退格鍵將具有相同的結果。

相關問題