Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to set the height of certain static UITableView cells and not all of them when conditions are met?
    primarykey
    data
    text
    <p>I have a UITableView with static cells and through a search the cells that don't match the search are hidden. Is there a way to set the row height of the cells that are hidden. I have tried to use if statements but they end up changing all the cells in the tableview and not the hidden ones. </p> <p>Basically I was wondering that when a cell is hidden if its row height can then be changed as well</p> <p>EDIT Sorry I was away from my code when I posted the question</p> <p>At the moment the I have the UITableView with static cells and a search bar with search display controller. The code is below for the search bar</p> <pre><code>@property (weak, nonatomic) IBOutlet UISearchBar *searchBar; @property (strong, nonatomic) IBOutletCollection(UITableViewCell) NSArray *cells; @property(nonatomic) CGFloat rowHeight; @implementation tableViewController @synthesize searchBar; @synthesize cells; @synthesize rowHeight; - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { for(UITableViewCell *cell in self.cells) { UILabel *label = cell.textLabel; NSString *text = label.text; cell.hidden = searchText.length != 0 &amp;&amp; ([text rangeOfString:searchText options:NSCaseInsensitiveSearch].location == NSNotFound); if (cell.hidden) { rowHeight = 10; } } } </code></pre> <p>This is what hides the cells that don't match. The problem i'm having is that when the cells are hidden they take up space in the display and to save space and to make things look better I want the hidden cells to be set to height of 0 OR 1 to save the space (10 is used as an example until I could get it to work) and to make everything line up. When the search bar is cancelled or clicked from it sets all the row heights back to 44. What happens with this code is that all the cells are set to 10 and not just the hidden ones.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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