IOS8 The core code of the Add complete button in the lower left corner of the numeric keypad is as follows:
-(void) adddonebuttontonumpadkeyboard{UIButton *donebutton = [UIButton buttonwithtype:uibuttontypecustom]; if (Systemversion < 8.0) {donebutton.frame = CGRectMake (0, 163, 106, 53); }else{donebutton.frame = CGRectMake (0, screen_size.height-53, 106, 53); } Donebutton.tag = Num_pad_done_button_tag; donebutton.adjustsimagewhenhighlighted = NO; [Donebutton settitle:@ "completed" forstate:uicontrolstatenormal]; [Donebutton Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal]; [Donebutton addtarget:self Action: @selector (Donebutton:) forcontrolevents:uicontroleventtouchupinside]; Nsarray *windowarr = [[UIApplication sharedapplication] windows]; if (Windowarr! = Nil && windowarr.count > 1) {UIWindow *needwindow = [Windowarr objectatindex:1]; UIView *keyboard; for (int i = 0; i < [needwindow.subviews count]; i++) {keyboard = [needwindow.subviews objectatindex:i]; if ([[[Keyboard DEscription] hasprefix:@ "<uiperipheralhostview"] = = YES) | | ([[Keyboard description] hasprefix:@ "<uikeyboard"] = = YES) | | ([[[Keyboard description] hasprefix:@ "<uiinputsetcontainerview"] = = YES)) {if ([[Keyboard subviews] count] <= 1) {[Keyboard Addsubview:donebutton]; }}}}}-(void) removedonebuttonfromnumpadkeyboard{UIView *donebutton = nil; Nsarray *windowarr = [[UIApplication sharedapplication] windows]; if (Windowarr! = Nil && windowarr.count > 1) {UIWindow *needwindow = [Windowarr objectatindex:1]; UIView *keyboard; for (int i = 0; i < [needwindow.subviews count]; i++) {keyboard = [needwindow.subviews objectatindex:i]; if ([[[Keyboard description] hasprefix:@ "<uiperipheralhostview"] = = YES) | | ([[Keyboard description] hasprefix:@ "<uikeyboard"] = = YES) | | ([[[Keyboard description] hasprefix:@ "<uiinputsetcontainerview"] = = YES)) { Donebutton = [keyboard Viewwithtag:num_pad_done_button_tag]; if (Donebutton! = nil) {[Donebutton Removefromsuperview]; } } } }}
Note:
After 1.ios8, the description of the keyboard view changes to start with <uiinputsetcontainerview , so you need to add this to the logic of the judgment.
After 2.ios8, the size of the keyboard view becomes the size of the entire screen, so you need to fit the position that the button was added to.
IOS8 the lower left corner of the numeric keypad add the Finish button