Receive notifications from the user’s “Finish” button on a numeric keypad that does not work in iOS 8.3

I added a custom “Finish” button to the numeric keypad using a solution hosted in other threads, like this one . Something has changed with the upgrade to iOS 8.3, as the button still appears, but touch notifications never work. Moving a button from the keyboard to the supervisor destroys the location of the button, but confirms notifications for the operation of the control.

It behaves as a user button is located behind a transparent layer on the keyboard, and no touch can take place.

- (void)addButtonToKeyboard { // create custom button self.doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; self.doneButton.frame = CGRectMake(0, 163+44, 106, 53); self.doneButton.adjustsImageWhenHighlighted = NO; [self.doneButton setTag:67123]; [self.doneButton setImage:[UIImage imageNamed:@"doneup1.png"] forState:UIControlStateNormal]; [self.doneButton setImage:[UIImage imageNamed:@"donedown1.png"] forState:UIControlStateHighlighted]; [self.doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside]; // locate keyboard view int windowCount = [[[UIApplication sharedApplication] windows] count]; if (windowCount < 2) { 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){ UIButton* searchbtn = (UIButton*)[keyboard viewWithTag:67123]; if (searchbtn == nil)//to avoid adding again and again as per my requirement (previous and next button on keyboard) [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){ UIButton* donebtn = (UIButton*)[hostkeyboard viewWithTag:67123]; if (donebtn == nil)//to avoid adding again and again as per my requirement (previous and next button on keyboard) [hostkeyboard addSubview:self.doneButton]; } } } } } 
+5
source share
2 answers

I had the same problem, I solved this problem by adding a button directly to UITextEffectsWindow. I also changed the frame of the button.

 - (void)addButtonToKeyboar { // create custom button self.doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; self.doneButton.frame = CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - 53, [[UIScreen mainScreen] bounds].size.width / 3, 53); self.doneButton.adjustsImageWhenHighlighted = NO; [self.doneButton setTag:67123]; [self.doneButton setImage:[UIImage imageNamed:@"doneup1.png"] forState:UIControlStateNormal]; [self.doneButton setImage:[UIImage imageNamed:@"donedown1.png"] forState:UIControlStateHighlighted]; [self.doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside]; // locate keyboard view int windowCount = [[[UIApplication sharedApplication] windows] count]; if (windowCount < 2) { return; } UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1]; UIButton* donebtn = (UIButton*)[tempWindow viewWithTag:67123]; if (donebtn == nil)//to avoid adding again and again as per my requirement (previous and next button on keyboard) [tempWindow addSubview:self.doneButton]; } 
+4
source

objectAtIndex: 1 cannot indicate a window index each time. Therefore, the code should check by its description whether the window is UITextEffectsWindow or not, as shown below.

 if (windowCount < 2) { return; } else { periodButton.frame = CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - 53, 106, 53); for (UIWindow *window in [[UIApplication sharedApplication] windows]) { if ([[window description] hasPrefix:@"<UITextEffectsWindow"]) { [window addSubview:periodButton]; } } } 
0
source

All Articles