objective c - UIKeyboardWillShowNotification calling twice ios 9 -
i using uikeyboardwillshownotificationto detect when textfield selecting user , keyboard opening. in ios 8 , older versions of ios working fine today upgrade ios 9 , xcode 7. problem in ios notification called after selecting each textfields (while in ios 8 called after selecting first textfield).
i searched , find post why uikeyboardwillshownotification called every time textfield selected?
but not ios 9 (actually every thing right in ios8 , upgrading see problem) , not using inputaccessoryviews too.
same problem here. have uitexfield in view controller , when leave textfield 1 programmatically using becomefirstresponder method, uikeyboardwillshownotification called once again. if keyboard not hide-and-show again. however, uikeyboardwillhidenotification not called.
i don't know why problem appeared in ios9 can give workaround. did : created bool property in view controller:
@property (assign, nonatomic) bool keyboardisshown; and in keyboard observers methods :
- (void)keyboardwillhidenotification:(nsnotification *)notification { self.keyboardisshown = no; //rest of code } - (void)keyboardwillshownotification:(nsnotification *)notification { if(self.keyboardisshown) { return; } self.keyboardisshown = yes; //some code } if has cleaner solution avoid uikeyboardwillshownotification called multiple times in ios9 when calling becomefirstresponder on uitextfield, take it!
Comments
Post a Comment