ios - UISearchController searchResultsController disappears when searchbar text is empty -
i have uisearchcontroller displays it's searchresultscontroller (which view controller) when searchbar tapped. using uisearchcontroller delegate method:
-(void)presentsearchcontroller:(uisearchcontroller *)searchcontroller { dispatch_async(dispatch_get_main_queue(), ^{ searchcontroller.searchresultscontroller.view.hidden = no; }); }
however, time searchbar's text empty, whether manually deleting text or tapping little x button, searchresultscontroller view disappearing until start typing text again. ideas why may happening? there method or delegate method being triggered when searchbar.text empty?
so after fiddling around while yesterday, solution found ended working. figured i'd post in case else has same problem!
-(void)presentsearchcontroller:(uisearchcontroller *)searchcontroller { //forces searchresultscontroller appear when searchbar tapped dispatch_async(dispatch_get_main_queue(), ^{ searchcontroller.searchresultscontroller.view.hidden = no; }); } -(void)searchbar:(uisearchbar *)searchbar textdidchange:(nsstring *)searchtext { //prevents searchcontroller disappearing if ([searchtext isequaltostring:@""]) { [self presentsearchcontroller:self.searchcontroller]; } }
Comments
Post a Comment