ios - Put UISearchBar in the middlel of navagation bar, no table view is shown when typing -


i set uisearchbar view controller's titleview. when type in uisearchbar, no table view shown.but before set uisearchbar view controller's titleview, works well.

 - (void)initsearchbar {     self.searchbar=[[uisearchbar alloc] initwithframe:cgrectmake(0, 0, 200, 30)];     self.searchbar.barstyle     = uibarstyleblack;     self.searchbar.translucent  = yes;     self.searchbar.delegate     = self;     self.searchbar.placeholder  = @"搜索";     self.searchbar.keyboardtype = uikeyboardtypedefault;      self.navigationitem.titleview=self.searchbar; }  - (void)initsearchdisplay {     self.displaycontroller = [[uisearchdisplaycontroller alloc] initwithsearchbar:self.searchbar contentscontroller:self];     self.displaycontroller.delegate                = self;     self.displaycontroller.searchresultsdatasource = self;     self.displaycontroller.searchresultsdelegate   = self;  } 

when use uisearchdisplaycontroller that's time uisearchdisplaycontroller call own tableview need check condition .

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { if (tableview==self.searchdisplaycontroller.searchresultstableview) {      return [searchalldata count];  }else{     return [arrdata count];  }  }    - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath     *)indexpath { if (tableview==self.searchdisplaycontroller.searchresultstableview) {  cell.textlabel.text=[searchalldata objectatindex:indexpath.row];  }else{ cell.textlabel.text=[arrdata objectatindex:indexpath.row];  }   } 

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 -