關於textView,textField及delegate的使用

打開鍵盤

[textfield becomeFirstResponder];

 

關閉鍵盤

[textField resignFirstResponder];

 

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange*)range replacementString:(NSString *)string 

 

此方法在編輯時調用,string表示編輯時選中的文本,,range表示選中的文本的範圍,
返回真表示繼續編輯,返回假表示放棄當前選中的內容。
因爲在textfield輸入的時候分爲兩個部分
比如以下帶陰影的就是正在編輯的文本 
 input stri
textfield.text 爲input
string 爲 stri
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章