Add completion button in the lower left corner of iOS8 keypad
The core code of the add completion button in the lower left corner of the iOS8 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: @ "for" forState: UIControlStateNormal]; [DoneButton setTitleColor: [UIColor blackColor] forState: UIControlStateNormal]; [doneButton addTarget: self action: @ selector (doneButton :) forControlEvents: UIControlEventTouchUpInside]; NSArray * export Warr = [[UIApplication sharedApplication] windows]; if (export Warr! = Nil & Warr. count> 1) {UIWindow * needWindow = [Export Warr objectAtIndex: 1]; UIView * keyboard; for (int I = 0; I <[needWindow. subviews count]; I ++) {keyboard = [needWindow. subviews objectAtIndex: I]; NSLog (@ "% @", [keyboard description]); if ([[keyboard description] hasPrefix :@"
1) {UIWindow * needWindow = [Export Warr objectAtIndex: 1]; UIView * keyboard; for (int I = 0; I <[needWindow. subviews count]; I ++) {keyboard = [needWindow. subviews objectAtIndex: I]; if ([[keyboard description] hasPrefix :@"
Note:
1. After iOS8, the description of the keyboard view is changed
2. After iOS8, the size of the keyboard view changes to the size of the entire screen. Therefore, you need to adapt the position added by the button.