I have UITextField and UIView animation which show and hide container with text field. If I edit text and then hide my text field, i see that text immediately change a frame at zero position, and then animate at normal place.
But it happens only at first hiding and only if some text inputed. I'll be grateful for any ideas!
There is show\hide action code:
- (IBAction)showOrHideSearchBar:(UIButton *)sender {
sender.selected = !sender.selected;
if (sender.selected) {
self.searchBarTopConstraint.constant = self.searchBarContainerView.frame.size.height;
[self.searchTextField becomeFirstResponder];
}
else {
self.searchBarTopConstraint.constant = 0;
[self.searchTextField endEditing:YES];
}
[UIView animateWithDuration:SEARCH_BAR_ANIMATION_DURATION animations:^{
[self.searchBarContainerView layoutIfNeeded];
}];
}