I have a search bar in my app in which I would like some animation to occur just before the keyboard shows up when the focus is placed in the search box. Is there a delegate method I can make use of to intercept before the keyboard is shown?
I am currently running the following code to detect when the UISearchBar has been activated:
-(void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar{
NSLog(@"Begin Editing");
CGRect newFrame = searchBar.frame;
newFrame.origin.y = 0;
[UIView animateWithDuration:0.25
animations:^{
searchBar.frame = newFrame;
[searchBar layoutSubviews];
}
completion:^(BOOL finished){
NSLog(@"Done!");
}
];
}
Can I delay the showing of the keyboard in anyway? Maybe call a halt to it and then show it in the completion handler?
you need to add an notification center to you code.
then declare a method named keyboardDidShow: and add the animation code to it.
there many options available. I guess
is also available. just check it if its there and it should work.
Cheers happy coding.!!