ios - How to Add search bar in table view -


Actually I have collected a lot of data in the table view and now I have to get my data easily, so I search bar Does anyone need some solution to me?

  - (NSInteger) table view: (UITableView *) table view numberoffrose injection: (NSInteger) section {return [array number]; } - (UITableViewCell *) TableView: (UITableView *) Table View CellForArendAppath: (NSINxpath *) Index Path {Fixed NSString * cellIdentifire = @ "Cell Identifier"; UITableViewCell * cell = [TablesView decomputer reusableWelcome Identifier: SimpleTable Identifier]; If (cell == blue) {cell = [[UITABLE DOCKEY alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: cellIdentifire]; } Cell.textLabel.text = [Array ObjectItendex: IndexPath.ro]; Return cell; }  

Follow these steps:

  • Drag and
  • set a representative for the search bar for your view controller

Use the following code for search:

  - (Zero) SearchbarIDDidBabins Edit: (UISearchBar *) Search Bar {[Search Bar SetsNationalBell button: Yes]; } - (Zero) Search Bar: (UISearchBar *) searchBar Text Did Change: (NSString *) searchText {// Delete all objects first [self search terms: search text]; } - Search (empty) BARCancelButtonClicked: (UISearchBar *) searchBar {NSLog (@ "Cancel Clicked"); SearchBar.text = @ ""; [Resigns the first responder]; [SearchSearchSetSensell button: No]; [Self show AllData]; // to show all the data} - (empty) Search button button: (UISearchBar *) Searchbar {nslog (@ "search on click"); [SearchSearchSetSensell button: No]; [Resigns the first responder]; [Self search term: searchBar.text]; } - (Zero) ShowAllData {// Load all data in _tableViewDataSourceArray, and reload table} - (zero) Search term: (NSString *) search text returns {if (searchText == zero); _tableViewDataSourceArray = // your search LOGIC [self.tableViewReloadData]; }  Edit:  If you want to create a search bar with code, start a search bar and see it at the top of your table view, inside  
  - (UIView *) TableView: (UITableView *) table view view FORHeaderInSection: (NSInteger) section  

not view

  - (CGFloat) Table View: (UITableView *) Table High Height FairHeader Injection: (NSInteger) section  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -