SearchResultsUpdating not being called in UISearchController

元气小坏坏 提交于 2019-12-12 04:41:40

问题


I'm working with UISearchController in Xamarin.Ios and everything works fine but when I start typing, the SearchhResultUpdating method is not override is not firing. It works sometimes and doesn't somw other times but now it doesn't work at all.

Here's the SearchResultsUpdating Class:

class SearchResult : UISearchResultsUpdating
{
    public event Action<string> UpdateSearchResults = delegate { };

    public override void UpdateSearchResultsForSearchController(UISearchController searchController)
    {

        this.UpdateSearchResults(searchController.SearchBar.Text);
    }
}

and Here's when I used it:

 var searchresult = new SearchResult();
 searchresult.UpdateSearchResults += searchResultsController.Search;
 var searchController = new UISearchController(searchResultsController) { SearchResultsUpdater = searchresult };

回答1:


You should make searchController as global variable .

If you do that , it won't release and keep in its life circle , and fire that method in UISearchResultsUpdating

Refer to this Demo



来源:https://stackoverflow.com/questions/46769598/searchresultsupdating-not-being-called-in-uisearchcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!