Ich habe eine benutzerdefinierte "Done" -Taste auf dem Ziffernblock mit einer Lösung in anderen Threads, like this one. Mit dem Update auf iOS 8.3 hat sich etwas geändert, da die Schaltfläche weiterhin angezeigt wird, jedoch keine Touch-Benachrichtigungen ausgelöst werden. Wenn Sie die Schaltfläche von der Tastaturansicht in die Superansicht bewegen, wird die Position der Schaltfläche gelöscht, die Benachrichtigungen für die Steuerung werden jedoch überprüft.Empfangen von Benachrichtigungen von benutzerdefinierten "Fertig" -Taste auf der numerischen Tastatur funktioniert nicht in iOS 8.3
Es verhält sich wie die benutzerdefinierte Schaltfläche ist hinter einer transparenten Schicht auf der Tastatur und keine Berührungen können stattfinden.
- (void)addButtonToKeyboard
{
// create custom button
self.doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.doneButton.frame = CGRectMake(0, 163+44, 106, 53);
self.doneButton.adjustsImageWhenHighlighted = NO;
[self.doneButton setTag:67123];
[self.doneButton setImage:[UIImage imageNamed:@"doneup1.png"] forState:UIControlStateNormal];
[self.doneButton setImage:[UIImage imageNamed:@"donedown1.png"] forState:UIControlStateHighlighted];
[self.doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
// locate keyboard view
int windowCount = [[[UIApplication sharedApplication] windows] count];
if (windowCount < 2) {
return;
}
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i = 0 ; i < [tempWindow.subviews count] ; i++)
{
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard found, add the button
if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES){
UIButton* searchbtn = (UIButton*)[keyboard viewWithTag:67123];
if (searchbtn == nil)//to avoid adding again and again as per my requirement (previous and next button on keyboard)
[keyboard addSubview:self.doneButton];
}//This code will work on iOS 8.0
else if([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] == YES){
for(int i = 0 ; i < [keyboard.subviews count] ; i++)
{
UIView* hostkeyboard = [keyboard.subviews objectAtIndex:i];
if([[hostkeyboard description] hasPrefix:@"<UIInputSetHost"] == YES){
UIButton* donebtn = (UIButton*)[hostkeyboard viewWithTag:67123];
if (donebtn == nil)//to avoid adding again and again as per my requirement (previous and next button on keyboard)
[hostkeyboard addSubview:self.doneButton];
}
}
}
}
}
funktioniert diese Lösung für alle Fälle. alle iPhones und alle iOS-Versionen? – hasan83
sicher, mein Projekt unterstützt iOS 7+ –