El teclado se oculta y se muestra de nuevo justo después de que UIActionSheet se cierre en iOS 7, SDK 7
Creo unUIActionSheet en mi ViewController. También agrego código para atraparUIKeyboardWill ShowNotification yUIKeyboardWillHideOotification notificación.
Mi problema esCuando salgo, me dan dos notificaciones de teclado ocultar y mostrar de nuevo. ¿Alguien me puede mostrar cómo prevenir ese problema? Solo sucede en iOS 7 y compila con SDK 7
Actualizar algún código:
En viewDidLoad, inicio un botón, cuando se toca el botón, se mostrará la hoja de acción.
- (void)viewDidLoad
{
[super viewDidLoad];
UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(10, 50, 100, 30);
[button setTitle:@"Open menu" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonTouched) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
UITextView* textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
[self.view addSubview:textView];
[textView becomeFirstResponder];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
}
- (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar{
[searchBar resignFirstResponder];
}
- (void) buttonTouched{
UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:@"Action sheet" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destructive" otherButtonTitles:@"Hello", nil];
[actionSheet showInView:self.view];
}
- (void)keyboardWillShow:(NSNotification*)notification{
NSLog(@"keyboardWillShow");
}
- (void)keyboardWillHide:(NSNotification*)notification{
NSLog(@"keyboardWillHide");
}
Ejecuto la aplicación, se muestra el teclado, toco el botón, se muestra la hoja de acción. Rechazo la hoja de acciones al tocar cualquier botón en ella, y registro Imprimir:
Teclado
teclado ocultar
Teclado