0

我最近遇到了一个问题。在我的应用程序中,我有一个 tabBar,其中两个选项卡包含一个 UISearchDisplayController。当我在两个 searchDisplayController 中进行研究,然后在选项卡之间切换时,它们显示相同的结果(最后一次搜索一个或另一个 searchDisplayController)。有没有办法避免这种情况?谢谢 !

4

1 回答 1

0

它们对应于 UISearchDisplayDelegate 的相同委托方法。您可以为它们分配标签以防止这种情况发生,或者您可以阅读标签栏的选定索引以查看用户在里面的位置

放置断点以查看两个 searchDisplayController 是否同时重新加载表。

- (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
 }

这样您就不会重新加载错误的委托。

于 2012-10-23T13:01:48.143 回答