0
我知道這裏有一些關於How to show button ‘Done’ on number pad on iPhone OS 4?的討論關閉數字鍵盤。我想找到一種方法來解除數字鍵盤w/o不得不添加一個UIToolbarButton。我的UITextFields是郵政編碼和age.The mint.com iPhone應用程序這樣做;所以必須有一個方法。關閉UITextField中的數字小鍵盤而不使用UIToolbarButton
這裏是我當前的代碼,增加了UIToolbarButton:
textField1.keyboardType = UIKeyboardTypeNumberPad;
textField1.delegate = self;
//Create a toolbar to add to the textpad
UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
numberToolbar.barStyle = UIBarStyleDefault;
numberToolbar.items = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(dismissZipKeyPad)],
nil];
[numberToolbar sizeToFit];
textField1.inputAccessoryView = numberToolbar;
如果你不想爲這個按鈕,什麼e發泄你想觸發鍵盤解僱? – rmaddy