1

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!

enter image description here

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];
    }];
}
Community
  • 1
  • 1
aquarium_moose
  • 355
  • 1
  • 11
  • If you want to animate u r textfield when text added or its selected, why can't you add your animation code into your if (sender.selected) block – MobileApp Developer Apr 02 '15 at 23:16
  • I want to show or hide container with textfield from navigation bar when button selected, no matter is there text or not. Anyway replacing code of animation have no effect – aquarium_moose Apr 03 '15 at 10:11

0 Answers0