Desidero utilizzare solo la tastiera alfabetica, come limitarla? Ho usato dichiarazione seguente, ma non nasconde il pulsante che converte tastiera in uno numericaTipo di tastiera UI
tempTextField.keyboardType = UIKeyboardTypeAlphabet;
Desidero utilizzare solo la tastiera alfabetica, come limitarla? Ho usato dichiarazione seguente, ma non nasconde il pulsante che converte tastiera in uno numericaTipo di tastiera UI
tempTextField.keyboardType = UIKeyboardTypeAlphabet;
sto abbiate timore, non è possibile limitare la tastiera per immettere solo caratteri alfabetici. I keyboardTypes disponibili sono elencati nel riferimento protocollo UITextInputTraits, e con ancora più dettagli nel file di intestazione:
typedef enum {
UIKeyboardTypeDefault, // Default type for the current input method.
UIKeyboardTypeASCIICapable, // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation.
UIKeyboardTypeURL, // A type optimized for URL entry (shows ./.com prominently).
UIKeyboardTypeNumberPad, // A number pad (0-9). Suitable for PIN entry.
UIKeyboardTypePhonePad, // A phone pad (1-9, *, 0, #, with letters under the numbers).
UIKeyboardTypeNamePhonePad, // A type optimized for entering a person's name or phone number.
UIKeyboardTypeEmailAddress, // A type optimized for multiple email address entry (shows space @ . prominently).
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated
} UIKeyboardType;
Mi sento quello che vuoi che manca dal SDK. Presenterei un bug report con Apple richiedendo un nuovo tipo di tastiera, come quello che hai menzionato.
Qual è la soluzione per voi oltre a presentare una segnalazione di bug e attendere che il nuovo tipo di tastiera sia disponibile nell'SDK? Controllo dell'input nel campo di testo. Questo può essere fatto assegnando la proprietà delegate di UITextField e implementando il metodo UITextFieldDelegate textField: shouldChangeCharactersInRange: replacementString: e restituisce SÌ solo se la stringa di sostituzione non contiene numeri.
HTH
i tipi di tastiera aggiornati
typedef NS_ENUM(NSInteger, UIKeyboardType) {
UIKeyboardTypeDefault, // Default type for the current input method.
UIKeyboardTypeASCIICapable, // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation.
UIKeyboardTypeURL, // A type optimized for URL entry (shows ./.com prominently).
UIKeyboardTypeNumberPad, // A number pad (0-9). Suitable for PIN entry.
UIKeyboardTypePhonePad, // A phone pad (1-9, *, 0, #, with letters under the numbers).
UIKeyboardTypeNamePhonePad, // A type optimized for entering a person's name or phone number.
UIKeyboardTypeEmailAddress, // A type optimized for multiple email address entry (shows space @ . prominently).
#if __IPHONE_4_1 <= __IPHONE_OS_VERSION_MAX_ALLOWED
UIKeyboardTypeDecimalPad, // A number pad with a decimal point.
#endif
#if __IPHONE_5_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
UIKeyboardTypeTwitter, // A type optimized for twitter text entry (easy access to @ #)
#endif
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated
};
C'è un'implementazione di quello che @drvdijk suggerisce qui: http://stackoverflow.com/questions/1013647/filtering-characters-entered-into- a-UITextField/1015262 # 1015262 – teabot