Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Row height is controlled via</p> <pre><code>- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { </code></pre> <p>So when you hide a row, however you are doing this, you could reload that particular row. The method above could check a BOOL on the cell and use that to determine the height returned.</p> <p>However there is another way to achieve what you want:</p> <p>Here is an example of how I filter a table. I have a standard UISearchBar at the top of my table which calls this method with the search text: (some of the method calls are part of my project.. but you should get the idea)</p> <p>Basically, it gives the tableview a different array of data, and then reloads the table. If the search is cancelled, or the searchText is blank - it will get my original tableData.</p> <pre><code>- (void) performSearchWithText:(NSString *)searchText { [super performSearchWithText:searchText]; if ([searchText length] &gt; 0) { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"title contains[cd] %@", searchText]; NSArray *filteredArray = [[self.setListController sets] filteredArrayUsingPredicate:predicate]; self.tableData = [NSArray arrayWithArray:filteredArray]; [self.tableView reloadData]; } else { self.tableData = [self.setListController sets]; [self.tableView reloadData]; } } </code></pre> <p>This works well for me. </p> <p>EDIT: or...........</p> <p>Now, if you want to continue doing it the way you are doing.. you could try this.... it doesn't look too efficient though, but you only have 32 cells, so it should be fine. Ideally though, you want to separate the data and view - so you search the data and tell the view to update. Currently you are searching text in the view. </p> <pre><code>- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { [self.hiddenCells removeAllIndexes]; for(UITableViewCell *cell in self.cells) { UILabel *label = cell.textLabel; NSString *text = label.text; BOOL shouldHide = searchText.length != 0 &amp;&amp; ([text rangeOfString:searchText options:NSCaseInsensitiveSearch].location == NSNotFound); if (shouldHide) { [self.hiddenCells addIndex:[self.tableView indexPathForCell:cell]]; } } [self.tableView reloadData]; } - (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (self.hiddenCells containsIndex:indexPath) { return 0.0f; } else { return 40.0f; } } </code></pre> <p>You also need to create this property: @property (nonatomic, retain) NSMutableIndexSet *hiddenCells;</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload