Searchbar animate cancel button
Hi,
I have a searchbar that is NOT connected to a table view. I wan't to mimic the animation of the cancel button when the searchbar gains focus if it's connected to a tableview.
On focus I set showCancel to true and on blur I set it to false. But this does not produce any animation.
Any ideas on how to get the animation?
4 Answers
-
I'm also looking to do this. did you figure it out?
Thanks
-
i've checked source code of SearchBar at github master branch and I think it's not possible at the moment. You can compile your own SDK to make it animated.
in: iphone/Classes/TiUISearchBar.m
About line 70:
Change:
[search setShowsCancelButton:[TiUtils boolValue:value]];
to
[search setShowsCancelButton:[TiUtils boolValue:value] animated:YES];
I haven't tried by myself but it would be very nice feature to make it optional (or just make it default, so no more ugly/instant visible/hidden cancel buttons).
-
If you look in the latest KitchenSink for Titanium 1.6.x you will see that table_view_api_search.js has the code you're looking for. :) Works flawless on my iPhone 4 and iPad 2!
Cheers,
Paul -
I logged an issue in Jira about this. Hopefully it can get addressed.