错误是 - 无法找到支持类型4的键盘iPhone-Portrait-NumberPad ;使用3876877096_Portrait_iPhone-简单Pad_Default在iOS 7完成数字键盘键完全没问题,但在iOS 8没有。我没有改变任何东西,但只更新ios8
定义SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(V)([[[的UIDevice currentDevice] systemVersion]比较:V选项:NSNumericSearch]!= NSOrderedAscending)这种解决方案
- (void)keyboardWillShow:(NSNotification *)note
{
// NSLog(@"keyboardwillshow");
doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
doneButton.frame = CGRectMake(0, 163, 106, 53);
doneButton.adjustsImageWhenHighlighted = NO;
[doneButton setTitle:@"Done" forState:UIControlStateNormal];
[doneButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[doneButton addTarget:self action:@selector(dismissKeyboard1) forControlEvents:UIControlEventTouchUpInside];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
dispatch_async(dispatch_get_main_queue(), ^{
// UIView *keyboardView = [[[[[UIApplication sharedApplication] windows] lastObject] subviews] firstObject];
// [doneButton setFrame:CGRectMake(0, keyboardView.frame.size.height - 53, 106, 53)];
// doneButton.frame = CGRectMake(0, ([UIScreen mainScreen].bounds.size.height-480)+163, 106, 53);
doneButton.frame = CGRectMake(0,163, 106, 53);
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
// NSLog(@"%f",keyboard.frame.size.height);
// keyboard found, add the button
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
[keyboard addSubview:doneButton];
} else {
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
[keyboard addSubview:doneButton];
}
}
// [keyboardView addSubview:doneButton];
// [keyboardView bringSubviewToFront:doneButton];
[UIView animateWithDuration:[[note.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]-.02
delay:.0
options:[[note.userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]
animations:^{
self.view.frame = CGRectOffset(self.view.frame, 0, 0);
} completion:nil];
});
}else {
// locate keyboard view
dispatch_async(dispatch_get_main_queue(), ^{
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard view found; add the custom button to it
if([[keyboard description] hasPrefix:@"UIKeyboard"] == YES)
[keyboard addSubview:doneButton];
}
});
}
}
去IGW?它不显示?它崩溃了吗?尽可能多地提供信息,不要过于宽泛或模糊 – 2014-09-22 08:34:15