Hey, all, I have one problem. I want to add done button to numeric keypad in ios and you for this following code. The problem is button not clickable after appearing. In my window I have table view with textfields.
- (void) hello:(id) sender { NSLog(@"helloooo"); } - (void)addButtonToKeyboard { if (!self.doneButton) { self.doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; [self.doneButton addTarget:self action:@selector(hello:) forControlEvents:UIControlEventTouchUpInside]; } self.doneButton.adjustsImageWhenHighlighted = NO; [self.doneButton setTitle:@"DONE" forState:UIControlStateNormal]; [self.doneButton.titleLabel setFont:[UIFont systemFontOfSize:16.0]]; [self.doneButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [self.doneButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted]; // locate keyboard view if ([[[UIApplication sharedApplication] windows] count] <= 1) return; UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1]; UIView* keyboard; for(int i=0; i<[tempWindow.subviews count]; i++) { keyboard = [tempWindow.subviews objectAtIndex:i]; // keyboard found, add the button if ([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES) { BOOL isPortrait = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation); self.doneButton.frame = CGRectMake(((isPortrait)?0:-1),((int) (keyboard.frame.size.height*3)/4) + ((isPortrait)?0:1),(int) keyboard.frame.size.width/3-1, (isPortrait)?60:40); [keyboard addSubview:self.doneButton]; } //This code will work on iOS 8.0 else if([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] == YES) { for(int i = 0 ; i < [keyboard.subviews count] ; i++) { UIView* hostkeyboard = [keyboard.subviews objectAtIndex:i]; if([[hostkeyboard description] hasPrefix:@"<UIInputSetHost"] == YES) { BOOL isPortrait = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation); self.doneButton.frame = CGRectMake(((isPortrait) ? 0 : -1),((int) (hostkeyboard.frame.size.height*3)/4) + ((isPortrait) ? 0 : 1),(int) hostkeyboard.frame.size.width/3-1, (isPortrait) ? 60 : 40); [hostkeyboard addSubview:self.doneButton]; } } } else{} } } -(void)textFieldDidBeginEditing:(UITextField *)textField { [self performSelector:@selector(addButtonToKeyboard) withObject:nil afterDelay:0.75]; }