I'm implementing a UISearchDisplayController in my iOS 7 & 8 app. I'm using Storyboards to build the interface, and I've successfully added the search controller to my table, and everything is hooked up fine, to the extent that searching works just fine.
My issue is that the table rows have been configured using Auto Layout to provide dynamic row heights based on the contents of the cells. While the layout is fine in the regular table, those constraints are not applied in the search results table. Here's some pretty pictures to show what I mean.
Every tutorial and bit of documentation assumes the results table will have a static height, and the advice is to use tableview.rowHeight
or return a float from tableView:heightForRowAtIndexPath
.
In the cellForRowAtIndexPath method, I'm dequeuing my cell from the regular tableview like so:
ScheduleTableViewCell * cell = [self.scheduleTable dequeueReusableCellWithIdentifier:@"cell"];
I would have expected this to use the cells as I've laid them out in the Storyboard, but that apparently doesn't include the constraints.
Is there some method I can kick to make this happen? Or do I need to manually determine each row's height like I did back before AutoLayout? Like some kind of filthy animal?
When using self-sizing cells, you should set the rowHeight property of both tables to UITableViewAutomaticDimension, and set the estimatedRowHeight for both tables as well. You can do this in viewDidLoad, there's no need to implement heightForRowAtIndexPath.