ios搜索栏范围按钮不会更新结果tableview

ios搜索栏范围按钮不会更新结果tableview,第1张

概述我正在尝试在我的表视图上实现搜索栏.当用户输入文本时,过滤效果很好.当搜索栏中有文本时,范围按钮也可以工作(它通过文本过滤过滤结果).我的问题是当搜索栏中没有文字时,范围按钮不起作用.过滤方法成功过滤数组;但是tableview没有更新.我试过; searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInte 我正在尝试在我的表视图上实现搜索栏.当用户输入文本时,过滤效果很好.当搜索栏中有文本时,范围按钮也可以工作(它通过文本过滤过滤结果).我的问题是当搜索栏中没有文字时,范围按钮不起作用.过滤方法成功过滤数组;但是tablevIEw没有更新.我试过;

searchbar:(UISearchbar *)searchbar selectedScopebuttonIndexDIDChange:(NSInteger)selectedScope

但它不起作用.我正在使用

-(BOol)searchdisplayController:(UISearchdisplayController *)controller shouldReloadtableForSearchString:(Nsstring *)searchString {// Tells the table data source to reload when text changes[self filterContentForSearchText:searchString                           scope:[[self.searchdisplayController.searchbar scopebuttonTitles] objectAtIndex:[self.searchdisplayController.searchbar selectedScopebuttonIndex]]];// Return YES to cause the search result table vIEw to be reloaded.return YES;

}

-(BOol)searchdisplayController:(UISearchdisplayController *)controller shouldReloadtableForSearchScope:(NSInteger)searchOption {// Tells the table data source to reload when scope bar selection changes[self filterContentForSearchText:self.searchdisplayController.searchbar.text                           scope:[[self.searchdisplayController.searchbar scopebuttonTitles] objectAtIndex:searchOption]];// Return YES to cause the search result table vIEw to be reloaded.return YES;

}

用于文本过滤.我也尝试重新加载数据,它也没有工作.我无法弄清楚为什么在文本更改后tablevIEw更新但在范围栏更改后它没有更新.

解决方法 我解决了这个问题.我不再使用searchdisplayController,而是使用textDIDChange和selectedScopebuttonIndexDIDChange.而不是使用两个表视图(normal和self.searchdisplayController.searchResultstableVIEw)我正在使用单表视图并且我更改其数据源,现在看来这解决了我的问题.但仍然无法弄清楚为什么应该调用divoadtableForSearchScope:不调用cellForRowAtIndexPath:并更新我的表视图 总结

以上是内存溢出为你收集整理的ios搜索栏范围按钮不会更新结果tableview全部内容,希望文章能够帮你解决ios搜索栏范围按钮不会更新结果tableview所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/999328.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-21
下一篇2022-05-21

发表评论

登录后才能评论

评论列表(0条)

    保存