我已经为iPhone和SDK下载了iOS 8 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];
}
}
}
}
到现在为止,这个工作一直很好。
首先,我收到以下警告:
找不到支持键盘iPhone-Portrait-NumberPad的类型4的键盘;使用3876877096_Portrait_iPhone-Simple-Pad_Default
那么该自定义按钮也不会显示,我认为是由于以下两行:
if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
和
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
有什么建议?