2012-04-05 2 views

답변

5

에서

감사합니다, 당신이 필요로하는 모든 키보드의 상단에 UIToolBar입니다!

UIToolBar Apple Doc

그리고, 그것을 수행하는 방법 :

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]; 
+1

코드에 몇 가지 오타가 수정되었으므로 괜찮습니다. – FelixLam

+1

내가 inputAccessoryView,이 힌트 안토니오 주셔서 감사! – Beppe

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]; 

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIToolbar_Class/Reference/Reference.html

이것은 도움이 될 수 있습니다 .. !!!

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를 추가하고 키보드에 직접 추가하지 않고 키보드를 표시하는 동시에 표시하는 것입니다.

관련 문제