简体   繁体   中英

can't use Frame.origin while setText

I'm using the next code to fadeout and scroll up my textfield but I just noticed that when I use something like [textField setText:@"something"]; or [textField resignFirstResponder]; I lose the scrolling up. Any one care to explain why I'm getting this behavior and a posibble workaround.

[UIView animateWithDuration:0.5
                          delay:0.0
                        options:UIViewAnimationCurveEaseInOut
                     animations:^ {
                         CGRect Frame = textField.frame;
                         Frame.origin.y=100;
                         textField.frame=Frame;
                        textField.alpha = 0.0;                        
                     }
                     completion:^(BOOL finished) {
                         textField.hidden = YES;
                     }];
    [textField resignFirstResponder];    
}

You should put the [textField resignFirstResponder]; into the completion block.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM