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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -