I have 2 tabs: radius search and location search. I am using UISearchBar in location search. The two tabs are woking perfectly, but when i search some results in search bar, then immediately click the radius tab, I am attempting to hide the searchbar.
I am using following code :
self.searchtextbar.hidden=YES;
self.searachtextbar=nil;
[self.searchtextbar removeFromSuperView];
The above three statements are executing, but it’s not working and search bar is not hiding.
please give any ideas to solve this problem.
You can not use
in this order. Once you set
self.searachtextbar=nil;you can not remove it from superview since you have set the value ofself.searachtextbaras nil. It is equivalent to[nil removeFromSuperView];which will not do anything.Also make sure that
self.searachtextbaris not nil before executingself.searchtextbar.hidden=YES;