¿Cómo podemos implementar UIKeyboardTypeNumberPad para que tenga un botón 'hecho'? Por defecto no tiene uno.UIKeyboardTypeNumberPad sin un botón hecho
Respuesta
Si no estoy equivocado, entonces desea preguntar cómo agregar un botón personalizado "Hecho" al teclado para UIKeyboardTypeNumberPad. En ese caso, esto podría ser útil. Declarar una in.h UIButton * DoneButton y agregue el código siguiente a .m archivo
- (void)addButtonToKeyboard {
// create custom button
if (doneButton == nil) {
doneButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 163, 106, 53)];
}
else {
[doneButton setHidden:NO];
}
[doneButton addTarget:self action:@selector(doneButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
// locate keyboard view
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard = nil;
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
// 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];
}
}
}
- (void)doneButtonClicked:(id)Sender {
//Write your code whatever you want to do on done button tap
//Removing keyboard or something else
}
estoy usando la misma en mi aplicación y el marco del botón se ajusta por lo tanto, este modo puede llamar [auto addButtonToKeyboard] cada vez que se necesita mostrar el botón hecho sobre el teclado. UIKeyboardTypeNumberPad no tiene el botón Hecho de lo contrario.
Tengo un problema con la línea UIWindow * tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex: 1]; Obtengo una matriz emty sin subvistas – user784625
Donde exactamente obtienes una matriz en blanco. En caso de que haya un teclado presente en la pantalla, obtendrá por lo menos un elemento en la matriz, es decir, el teclado. –
He agregado la llamada a esta función una vez en keyboardwilllshow y keyboarddidshow pero sigo recibiendo el arreglo – user784625
iOS 5 problema resuelto. Un millón de gracias.
Tuve un problema al mostrar el botón Hecho.
sustituida:
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
[keyboard addSubview:doneButton];
que no muestra el botón hecho en iOS 5 ...
Con:
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];
}
funcionaba un lujo. Eres una estrella. Gracias, Nicola ;-)
Si alguien tuvo un problema con el botón DONE que sigue apareciendo cuando intenta cargar otros tipos de teclados en la misma aplicación, sé que muchas aplicaciones tienen este problema. De todos modos, así es como resolví esto: En su ViewController (el mismo controlador de vista que ha agregado el botón DONE) agregue este código (tal como está) y debería resolver sus problemas con el botón DONE continuar reapareciendo. Espero que ayude a algunas personas.
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidHideNotification object:nil];
} else {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardDidShowNotification object:nil];
//Call this method
- (void)keyboardWillShow:(NSNotification *)note {
UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 163, 106, 53)];
doneButton.adjustsImageWhenHighlighted = NO;
[doneButton setImage:[UIImage imageNamed:@"Done.png"] forState:UIControlStateNormal];
[doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
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];
}
}
}
- 1. ¿Cómo agregar el botón Hecho al teclado?
- 2. iphone UISearchBar Botón hecho siempre habilitado
- 3. Agregando un botón derecho "hecho" (UIBarButtonItem) a un UINavigationController
- 4. UITextView con el botón "Hecho" * y * ¿"Volver"?
- 5. ¿Escucha el botón Hecho en EditText?
- 6. Android HTML formulario 'hecho' botón sofkeyboard
- 7. El botón jquerymobile hecho clic en azul
- 8. iOS Xcode teclado hecho botón función
- 9. ¿Cómo agregar un botón hecho sobre la vista de selección?
- 10. ¿Cómo puedo obtener un botón "hecho" en el teclado?
- 11. UIKeyboardTypeNumberPad - ¿Mostrar solo numbes en el iPad?
- 12. Cómo deshabilitar el botón "Siguiente" en un teclado de software EditText (reemplace con el botón "Hecho")
- 13. ¿Cómo descarto una UITextView usando el botón del teclado Hecho?
- 14. iPad SDK: ¿Cómo conectar el botón hecho de MPMoviePlayerViewController?
- 15. JQuery UI Datepicker - Cómo eliminar el botón "Hecho"
- 16. Manejo del botón 'Hecho' en el teclado fuera de textViewDidEndEditing
- 17. Cambiando el texto del botón hecho en el teclado
- 18. Teclado suave de Android personalizado Texto del botón "Hecho"?
- 19. UIAlertView sin botón Cancelar?
- 20. Botón WPF Sin borde Sin fondo
- 21. botón sin devolución de datos?
- 22. Pepino, capibara y selenio: enviar un formulario sin un botón
- 23. Quitar el botón 'anterior', 'siguiente' y 'hecho' en el formulario html
- 24. ¿Cómo puedo saber si un usuario ha hecho clic en el botón Me gusta de Facebook en mi sitio web?
- 25. Crear un botón de tweet sin abrir una nueva ventana
- 26. Cómo desencadenar la validación sin utilizar un botón de envío
- 27. Presentar sin el uso de un botón de enviar, Mecanizar
- 28. Cómo crear un botón sin icono en CKEditor
- 29. Registro hecho bien
- 30. ¿Cómo obtengo el botón hecho para que aparezca en el teclado virtual?
¿Qué quiere decir mediante la aplicación de teclado, que desea ocultar el teclado o cualquier cosa ELSS. – Ishu
No ... Solo que no habrá un botón hecho en el teclado – Abhinav
Estimado pad numérico que no tiene ningún botón Hecho. De modo que su pregunta no es válida. – Ishu