0

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.

4
  • In which method you have above code ? Commented Oct 13, 2012 at 6:47
  • in radius tab, as well as in viewwillAppear Commented Oct 13, 2012 at 6:49
  • use viewwillDisappear in Location. Commented Oct 13, 2012 at 6:51
  • i already used these 3 statements in viewWillDisappear, viewdidDisappear and viewDidUnload, but still not working Commented Oct 13, 2012 at 7:00

1 Answer 1

0

You can not use

self.searachtextbar=nil; [self.searchtextbar removeFromSuperView]; 

in this order. Once you set self.searachtextbar=nil; you can not remove it from superview since you have set the value of self.searachtextbar as nil. It is equivalent to [nil removeFromSuperView]; which will not do anything.

Also make sure that self.searachtextbar is not nil before executing self.searchtextbar.hidden=YES;

Sign up to request clarification or add additional context in comments.

Comments