確保使用者輸入內容的Auto-enable Return Key

為了防止使用者忘了輸入表單欄位的內容,我們常常要費心地加上字串是否為空的檢查。其實有更簡單的方法,不管是單行的Text Field或多行的Text View,都可藉由勾選Auto-enable Return Key,讓使用者在輸入文字後才能按下return鍵。

想從程式設定也可以,將Text Field或Text View的enablesReturnKeyAutomatically設為true。

執行結果:

當Text Field裡一個字都沒有時,return鍵無法點選。

一旦Text Field裡有一個字,即可點選return鍵。(空白也算)

results matching ""

    No results matching ""