Reputation: 303
I get twice notification on keyboard down and once on keyboard up…
In my class I put notifications for keyboard:
-(id)init… {
…
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
…
}
to do frame adjustment on keyboard slide.
Later during the class work I use 'ABPeoplePickerNavigationController'
to select address.
…
ABPeoplePickerNavigationController *userPicker=[[ABPeoplePickerNavigationController alloc] init];
…
[viewController presentModalViewController:userPicker animated:YES];
…
I’ve found that on ‘presentModalViewController’
I get twice ‘UIKeyboardWillHideNotification’
, BUT once ‘UIKeyboardWillShowNotification’
– when the picker goes out.
Pretty strange.
I tried to remove observer for ‘UIKeyboardWillHideNotification’
from the class initialization (to find any double observer declarations). However, after this remove no ‘UIKeyboardWillHideNotification’
notifications at all.
Why I get different amount of notifications on keyboard up and down?
May be I do something wrong?
Thanks.
Upvotes: 1
Views: 2036
Reputation: 2530
It is quite common (especially with the *WillDoSomething message) to receive a notification twice though you expected just once. What you could do to fix the problem is to have a boolean somewhere which stores the state of the UI. For instance, if keyboardUp is false would mean that you already move the UI to the default state.
Upvotes: 1