鍵盤的相關設定 UITextfield

2021-09-01 19:29:16 字數 1878 閱讀 6629

一、鍵盤風格   

uikit框架支援8種風格鍵盤。

typedefenumuikeyboardtype;  

用法用例:

textview.keyboardtype = uikeyboardtypenumberpad;

二、鍵盤外觀

typedefenumuireturnkeytype;  

用法用例:

textview.returnkeytype=uireturnkeygo;

四、自動大寫

typedefenumuitextautocapitalizationtype;  

用法用例:

textfield.autocapitalizationtype

= uitextautocapitalizationtypewords

;五、自動更正

typedefenumuitextautocorrectiontype;  

用法用例:

textfield.autocorrectiontype= uitextautocorrectiontypeyes;

六、安全文字輸入

textview.securetextentry=yes;

開啟安全輸入主要是用於密碼或一些私人資料的輸入,此時會禁用自動更正和自此快取。

統計字元和響應return鍵

統計字元:

1、uitextview

- (void)textviewdidchange:(uitextview *)textview

2、uitextfield

方法一:

自己先為uitextfield的editing changed事件新增乙個響應方法

-(ibaction)valuechange//

m_textfield是uitextfield的乙個iboutlet

}

方法二:

在**方法:- (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string,判斷range.length的值來判斷輸入的是回格還是其它字元

響應return鍵

1、uitextview

//**方法

- (bool)textview:(uitextview *)textview shouldchangetextinrange:(nsrange)range replacementtext:(nsstring *)text

if ([text isequaltostring:@"

\n"]) else

}return no;

}

2、uitextfield

這個直接有**方法哈

- (bool)textfieldshouldreturn:(uitextfield *)textfield

uitextfield進入編輯狀態 獲得焦點 

becomefirstresponder

關閉鍵盤 resignfirstresponder

鍵盤的相關設定

一 鍵盤風格 uikit框架支援8種風格鍵盤。typedefenumuikeyboardtype 用法用例 textview.keyboardtype uikeyboardtypenumberpad 二 鍵盤外觀 typedefenumuireturnkeytype 用法用例 textview.re...

IOS鍵盤的相關設定 UITextfield

一 鍵盤風格 uikit框架支援8種風格鍵盤。typedefenumuikeyboardtype 用法用例 textview.keyboardtype uikeyboardtypenumberpad 二 鍵盤外觀 typedefenumuireturnkeytype 用法用例 textview.re...

IOS鍵盤的相關設定 UITextfield

一 鍵盤風格 uikit框架支援8種風格鍵盤。typedefenumuikeyboardtype 用法用例 textview.keyboardtype uikeyboardtypenumberpad 二 鍵盤外觀 typedefenumuireturnkeytype 用法用例 textview.re...