这个NumberPad键盘什么时候能解决? – 帮帮我!

我真的不知道苹果为什么不把DONEbutton放在NumberPad键盘上。

有一些可用的解决scheme,但升级4.2禁用它们。

我正在为4.2的问题寻找一个解决scheme。 另外,如果可能的话,有关是否可以创build一个开源,易于集成,解决scheme的答案 ,以便我可以\做并发布。

此外,我想知道如何拒绝closures键盘,如果input不正确(这是一个可能的丑陋的解决scheme – 确保没有input回字符)

谢谢。

虽然在iOS 4.2之前的解决scheme似乎不再起作用,但是我正在使用的解决scheme是通过观察UIKeyboardWillAppearNotification为UIWindow添加一个button。 经过一小段时间,我迅速淡入button。 不理想; 但看起来并不可怕。

我也观察到UIKeyboardWillHideNotification。 在这里,淡出会是难看的,因为当键盘在下面滑动时它会消失。 为了提供键盘和解除button一起解除的错觉,我在退色时略微滑动解除button:

_keyboardDisappearanceObserver = [[NOTIFIER addObserverForName:UIKeyboardWillHideNotification object:nil queue:nil usingBlock:^(NSNotification *note) { [UIView animateWithDuration:0.1 animations:^(void) { _dismissButton.alpha = 0.0; CGRect buttonFrame = _dismissButton.frame; buttonFrame.origin.y += 25; _dismissButton.frame = buttonFrame; } completion:^(BOOL finished) { [_dismissButton removeFromSuperview]; CGRect buttonFrame = _dismissButton.frame; buttonFrame.origin.y -= 25; _dismissButton.frame = buttonFrame; }]; }] retain]; 

也许类似的解决scheme可以用于键盘外观。

顺便说一句,我find了解雇button: UIControlStateNormalbutton和UIControlStateHighlightedbutton

不是我的解决scheme,我在拖网之后发现了一些博客文章。 适用于iOS 5.0

 - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; } - (void)keyboardDidShow:(NSNotification *)note { [self addDoneButtonToKeyboard]; } -(void)addDoneButtonToKeyboard { UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; doneButton.adjustsImageWhenHighlighted = NO; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.0) { [doneButton setImage:[UIImage imageNamed:@"DoneUp3.png"] forState:UIControlStateNormal]; [doneButton setImage:[UIImage imageNamed:@"DoneDown3.png"] forState:UIControlStateHighlighted]; } else { [doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal]; [doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted]; } [doneButton addTarget:self action:@selector(resignTextView:) forControlEvents:UIControlEventTouchUpInside]; UIWindow* keyboardView = [[[UIApplication sharedApplication] windows] objectAtIndex:1]; [self insertDoneKey:keyboardView button:doneButton]; } - (void)insertDoneKey:(UIView*)view button:(UIButton*) button { int keyIndex = 0; for (UIView* subview in view.subviews) { if([[subview description] rangeOfString:@"UIKBKeyView"].location!=NSNotFound) { // NSLog(@"Found Keyboard KeyIndex:%d descr: %@",keyIndex,[subview description]); if (keyIndex==9) { // NSLog(@"Returning bottom left key view"); button.frame=CGRectMake(0, 0, subview.frame.size.width, subview.frame.size.height); button.bounds=CGRectMake(0, 0, subview.frame.size.width, subview.frame.size.height); [subview setUserInteractionEnabled:YES]; [subview addSubview:button]; [subview bringSubviewToFront:button]; } keyIndex++; } [self insertDoneKey:subview button:button]; } }