Клавиатуру спрятать и показать снова сразу после закрытия UIActionSheet в iOS 7, SDK 7
Я создаюUIActionSheet в моем ViewController. Я также добавляю код, чтобы пойматьUIKeyboardWillShowNotification а такжеUIKeyboardWillHideNotification уведомление.
Моя проблемакогда я увольняюсь, я получаю две скрытые клавиатуры уведомления и показываю снова, Кто-нибудь может показать мне, как предотвратить эту проблему? Это происходит только в iOS 7 и сборка с SDK 7
Обновите некоторый код:
В viewDidLoad я запускаю кнопку, когда при нажатии кнопки будет показан лист действий.
- (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");
}
Я запускаю приложение, клавиатура показывается, я нажимаю кнопку, лист действий показывает. Я закрываю лист действий, нажимая любую кнопку на нем, и регистрирую печать:
keyboardWillShow
keyboardWillHide
keyboardWillShow