这里面有个问题,在6P上不显示
- (void)addDoneButtonToNumPadKeyboard
{
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
// if (IOS_8_OR_LATER == 0){
// doneButton.frame = CGRectMake(0, 3*(self.boardHeight-3)/4.0f, (kScreenWidth-4)/3.0f, (self.boardHeight-3)/4.0f);
// }else{
// doneButton.frame = CGRectMake(0, kScreenHeight-(self.boardHeight-3)/4.0f, (kScreenWidth-4)/3.0f, (self.boardHeight-3)/4.0f);
// }
if (IOS_8_OR_LATER == 0){
doneButton.frame = CGRectMake(0, 163, 106, 53);
}else{
doneButton.frame = CGRectMake(0, kScreenHeight-53, 106, 53);
}
doneButton.backgroundColor = [UIColor redColor];
doneButton.tag = 100000000;
doneButton.adjustsImageWhenHighlighted = NO;
[doneButton setTitle:@"完成" 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:100000000];
if (doneButton != nil){
[doneButton removeFromSuperview];
}
}
}
}
}
- (void)doneButton:(UIButton *)doneButton
{
[self.view endEditing:YES];
}