I have one ViewController with custom view class. I have handled keyboard notification by adding into viewWillAppear method and remove notification in viewDidDisappear.
Notification adding into viewWillAppear:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector (keyboardWillShow:)
name: UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector (keyboardWillHide)
name: UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector (keyboardDidHide)
name: UIKeyboardDidHideNotification object:nil];
Remove Notification into viewDidDisappear:
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object: nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object: nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidHideNotification object: nil];
and call view's method from viewController's notification method.
Issue:
- After tapping on UITextField, keyboard appear and properly animation done
- But after keyboard appear, if user press back button from navigation-bar then keyboard will not remove after ViewController disappear from screen.
- Now user not able to close keyboard
If I remove notification code then worked perfectly.
Before iOS 7.0, its works perfectly with notification code. But in iOS 7.0, its not work.
I have print NSLog in each notification method, in IOS 7.0 keyboardWillShow method executes at last and again keyboard appear. But in iOS 6.0, keyboardWillShow not execute at last.
I have also implements UITextFieldDelegate methods.
Thanks in advance