ios - UISearchBar with hidden TableView on NavigationBar -


i trying create view searchbar on navigationbar, want searchbar open tableview search results typing begins, , hide once item touched. new platform, need path follow, don't know start actually.

according comment: heres more in depth explanation. happy coding:

.h

@interface tableviewcontroller : uitableviewcontroller <uisearchbardelegate>  @property (strong, nonatomic) uisearchbar *searchbar;  @end 

.m

- (void) viewdidload:(bool)animated {  uiview *searchbarview = [[uiview alloc] initwithframe:cgrectmake(0, 0, self.view.bounds.size.width, 44)]; //this adds container hold search bar.  self.searchbar = [[uisearchbar alloc] initwithframe:cgrectmake(0, 0, self.view.bounds.size.width, 44)];  self.searchbar.delegate = self; [searchbarview addsubview:self.searchbar]; self.tableview.tableheaderview = searchbarview; //inserts uiview header of self.tableview [self.tableview setcontentoffset:cgpointmake(0, 44)]; } 

and thats pretty it. if want customize other things keyboard layout , way text populates , color , font , placeholder text etc, can edit in viewdidload or make subclass

edit have included example code customization below:

self.searchbar.keyboardappearance = uikeyboardappearancedark; self.searchbar.returnkeytype = uireturnkeysearch; self.searchbar.searchbarstyle = uisearchbarstyleprominent; self.searchbar.bartintcolor = [uicolor lightgraycolor]; self.searchbar.placeholder = @"search queries here"; self.searchbar.showscancelbutton = yes; [[uibarbuttonitem appearancewhencontainedin:[uisearchbar class], nil] settitletextattributes:[nsdictionary dictionarywithobjectsandkeys:                                                                                               [uicolor bluecolor],                                                                                               nsforegroundcolorattributename,                                                                                               nil]                                                                                     forstate:uicontrolstatenormal];  -(void)searchbarcancelbuttonclicked:(uisearchbar *)searchbar { self.searchbar.showscancelbutton = no; [self.searchbar resignfirstresponder]; } 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -