I am making a custom table cell with InterfaceBuilder. However, when I change the height in IB, the changes are not reflected in the running program. Is there anything else I need to do besides set the height in IB?
Thanks in advance.
To change the height of tableView cell in ios dynamically, i.e resizing the cell according to the content available, we'll need to make use of automatic dimension property.
There are two main base ways to populate a tableview. The more popular is through Interface Building, using a prototype cell UI object. The other is strictly through code when you don't need a prototype cell from Interface Builder.
indexPath(for:)Returns an index path that represents the row and section of a specified table-view cell.
Changing the height of your custom cell in IB is not enough. The height of a row in a UITableView can be controlled in 2 ways
Set the tableview.rowHeight
property to the desired value if you know all cells will be the same height. You can also set this in IB if i'm not mistaken.
Implement the UITableViewDelegate method
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
This method takes precedence, meaning that if you implement this method then the value you set in tableView.rowHeight
is ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With