国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

UITextFieldDelegate協議

2019-11-14 18:37:31
字體:
來源:轉載
供稿:網友

 

很多人都認為UITextField很簡單,為什么會寫這個協議呢?

因為在實際開發中可能會用到;

 

比如要做到下圖的效果:

文本框下面的下劃線的顏色要隨著輸入的狀態變化;

點擊對應的文本框,其下面的線條變為綠色,結束編輯,變為灰色;

要熟悉UITextFieldDelegate協議才能做到這一點;

首先,先看一下官方的說明:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;        // return NO to disallow editing.- (void)textFieldDidBeginEditing:(UITextField *)textField;           // became first responder- (BOOL)textFieldShouldEndEditing:(UITextField *)textField;          // return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to end- (void)textFieldDidEndEditing:(UITextField *)textField;             // may be called if forced even if shouldEndEditing returns NO (e.g. view removed from window) or endEditing:YES called- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;   // return NO to not change text- (BOOL)textFieldShouldClear:(UITextField *)textField;               // called when clear button PRessed. return NO to ignore (no notifications)- (BOOL)textFieldShouldReturn:(UITextField *)textField;              // called when 'return' key pressed. return NO to ignore.

 

1、

- (void)textFieldDidBeginEditing:(UITextField *)textField;

文本框已經開始編輯

2、

- (void)textFieldDidEndEditing:(UITextField *)textField; 

文本框已經結束編輯

 

3、其他設置是否允許的輸入控制

1、- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;        // return NO to disallow editing.
//控制是否允許輸入,返回值是NO的時候,禁止輸入;

2、- (BOOL)textFieldShouldEndEditing:(UITextField *)textField; // return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to end //是否結束輸入,返回值是YES時候,允許停止輸入,并且釋放第一響應;返回NO的時候,則相反;3、- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; // return NO to not change text
//是否改變輸入文本,返回NO的時候,不保存修改
4、- (BOOL)textFieldShouldClear:(UITextField *)textField; // called when clear button pressed. return NO to ignore (no notifications)
//當清空按鈕時候調用,返回是NO的時候,忽視清空
5、- (BOOL)textFieldShouldReturn:(UITextField *)textField; // called when 'return' key pressed. return NO to ignore.
   //當點擊return按鈕時候調用該方法,返回是NO的時候,不做任何響應;

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 定兴县| 靖安县| 沙雅县| 平阳县| 宕昌县| 房山区| 金堂县| 眉山市| 四会市| 鄂州市| 海安县| 明水县| 宣化县| 新巴尔虎右旗| 漠河县| 昌乐县| 桐柏县| 娄底市| 蓬莱市| 禄劝| 西林县| 绍兴市| 浦北县| 新兴县| 庐江县| 东乌珠穆沁旗| 永川市| 台北县| 定陶县| 吉安县| 巨鹿县| 芮城县| 团风县| 阳高县| 龙口市| 建宁县| 古浪县| 建阳市| 资源县| 曲松县| 涿鹿县|