내 고객이 숫자 키패드를 사파리에서 볼 수 있도록 만들어달라고 요청했습니다. 사파리에서 키패드는 이전에 다음에 완료된 상단에 3 개의 버튼이 추가로 표시됩니다. 나는 같은 것을 달성하고 싶다. 이것을 달성하는 방법을 말해주십시오. 사전iPhone에서 사파리 키보드와 같은 응용 프로그램 키보드를 만드는 방법은 무엇입니까?
아주 쉽게
4
A
답변
5
에서
감사합니다, 당신이 필요로하는 모든 키보드의 상단에 UIToolBar입니다!
그리고, 그것을 수행하는 방법 :
UIToolbar *myToolBar = [[UIToolbar alloc] init];
myToolBar.barStyle = UIBarStyleDefault;
[myToolBar sizeToFit];
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(buttonClicked:)];
NSArray *array = [NSArray arrayWithObject:leftBarButton];
[leftBarButton release];
[myToolBar setItems:array];
myTextField.inputAccessoryView = myToolBar;
[myToolBar release];
0
가의 UITextField에 대한 keyboardType 속성이있다 :
는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;
코드는 읽어야
if(user is prompted for numeric input only)
[textField setKeyboardType:UIKeyboardTypeNumberPad];
if(user is prompted for alphanumeric input)
[textField setKeyboardType:UIKeyboardTypeDefault];
이것은 도움이 될 수 있습니다 .. !!!
0
UITextField
에는 필요한 키보드를 설정하는 데 유용한 속성 (keyboardType
)이 있습니다. 당신은 3 개 버튼하다면 상단 표시 줄을받지 않습니다, 어쨌든 http://gprince.yolasite.com/index/uikeyboardtype
:이 주소로 스크린 샷을 찾을 수 있습니다
UIKeyboardTypeDefault
UIKeyboardTypeASCIICapable
UIKeyboardTypeNumbersAndPunctuation
UIKeyboardTypeURL
UIKeyboardTypeNumberPad
UIKeyboardTypePhonePad
UIKeyboardTypeNamePhonePad
UIKeyboardTypeEmailAddress
:
aTextField.keyboardType = UIKeyboardTypeDefault;
keyboardType는 다음 중 하나 일 수 있습니다 키보드를 UIWebView
에 표시하지 마십시오. 해결 방법은 원하는 바를 포함하는 UIView를 키보드 상단에 추가하는 것입니다. 그러나 앱이 거부 될 수 있습니다. 이 문제에 관해 인터넷에서 많은 토론이 있습니다.
내 개인적인 해결책은 NIB보기에 UIView를 추가하고 키보드에 직접 추가하지 않고 키보드를 표시하는 동시에 표시하는 것입니다.
코드에 몇 가지 오타가 수정되었으므로 괜찮습니다. – FelixLam
내가 inputAccessoryView,이 힌트 안토니오 주셔서 감사! – Beppe