我已经为 iPhone 和 SDK 下载了 iOS8 Gold Master。
我测试了这个应用程序,它运行良好,除了一件事。
我有一个文本字段,如果用户想要输入一些东西,一个数字板将出现,此外,一个自定义按钮被添加到空白区域时,键盘显示。
- (void)addButtonToKeyboard
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
// create custom button
UIButton * doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
doneButton.frame = CGRectMake(-2, 163, 106, 53);
doneButton.adjustsImageWhenHighlighted = NO;
[doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
[doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
[doneButton addTarget:self action:@selector(saveNewLead:) forControlEvents:UIControlEventTouchUpInside];
// locate keyboard view
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 ([[[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];
}
}
}
}
到目前为止,一切都很顺利。
首先,我得到一个警告:
找不到支持键盘类型4的键盘 使用 3876877096 _ Portrait _ iPhone-Simple-Pad _ Default 3876877096 _ Portrait _ iPhone-Simple-Pad _ Default
然后那个自定义按钮也没有显示,我想是因为这两行:
if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
还有
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
有什么建议吗?