Somehow i dun know why does the default animation fails.
my Search bar did not shift up as it supposed to be.
the view is in UIView, i'm wondering if this is the problem.
Included the IB layout
The searchbar doesn't actually move in the 'push-up' animation. Rather it stays in place while the navbar goes up, thus pulling the rest of the view with it. You should be able to move the search bar manually in code by registering as its delegate (UISearchBarDelegate) and responding to these calls.
#pragma mark - UISearchBarDelegate Methods
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
//move the search bar up to the correct location eg
[UIView animateWithDuration:.4
animations:^{
searchBar.frame = CGRectMake(searchBar.frame.origin.x,
0,
searchBar.frame.size.width,
searchBar.frame.size.height);
}
completion:^(BOOL finished){
//whatever else you may need to do
}];
}
- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar {
//move the search bar down to the correct location eg
[UIView animateWithDuration:.4
animations:^{
searchBar.frame = CGRectMake(searchBar.frame.origin.x,
/*SearchBar original Y*/,
searchBar.frame.size.width,
searchBar.frame.size.height);
}
completion:^(BOOL finished){
//whatever else you may need to do
}];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With