ios - UISearchBar stays when seguing to another view controller via push -


i followed guide: http://www.jhof.me/simple-uisearchcontroller-implementation/

the difference in code is

instead of self.tableview.tableheaderview = self.searchcontroller.searchbar;

i have self.navigationitem.titleview = self.searchcontroller.searchbar;

when segue results table view controller, uisearchbar stays in navigation bar.

i rewrite sample apple, can see comment self.tableview.tableheaderview = self.searchcontroller.searchbar; set navigation bar's title view, you. can find search bar here in snapshot.

- (void)viewdidload {     [super viewdidload];      aplresultstablecontroller *qresultstablecontroller = [[aplresultstablecontroller alloc] init];     self.resultstablecontroller = qresultstablecontroller;     _searchcontroller = [[uisearchcontroller alloc] initwithsearchresultscontroller:qresultstablecontroller];     self.searchcontroller.searchresultsupdater = self;     [self.searchcontroller.searchbar sizetofit]; //    self.tableview.tableheaderview = self.searchcontroller.searchbar;     self.navigationitem.titleview = self.searchcontroller.searchbar;     self.searchcontroller.hidesnavigationbarduringpresentation = no;      // want delegate our filtered table didselectrowatindexpath called both tables     self.resultstablecontroller.tableview.delegate = self;     self.searchcontroller.delegate = self;     self.searchcontroller.dimsbackgroundduringpresentation = no; // default yes     self.searchcontroller.searchbar.delegate = self; // can monitor text changes + others      // search presenting view controller. such, normal view controller     // presentation semantics apply. namely presentation walk view controller     // hierarchy until finds root view controller or 1 defines presentation context.     //     self.definespresentationcontext = yes;  // know want uisearchcontroller displayed } 

snapshot here,

enter image description here

uisearchbarcontroller has property named hidesnavigationbarduringpresentation default yes, set no if want use navigation item's title view

self.searchcontroller.hidesnavigationbarduringpresentation = no; 

i have tested, works. hope helpful.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -