0

I encountered a problem recently. In my application, I have a tabBar in which two tabs contain a UISearchDisplayController. When I make a research in both searchDisplayController, and then switching between tabs, they are showing the same result (the last search of one or the other searchDisplayController). Is there a way to avoid this ? Thanks !

Matthias
  • 999
  • 11
  • 25

1 Answers1

0

they correspond to same delegate methods of UISearchDisplayDelegate. You can assign them tags to prevent this or you can read the selected index of tabbar to see where the user is inside

Put breakpoints to see if both searchDisplayControllers reload the tables simultaneously.

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption {
   //selected index of tabbar is the right one return yes
   if(self.tabBarController.selectedIndex ==1){
   return YES;
   }else{
   return NO;
   }
   //else no
 }

So that you do not reload the wrong delegate.

Ilker Baltaci
  • 11,644
  • 6
  • 63
  • 79