开发者

UITableViewCell height is not changing in UITableView when changing it in Interface Builder

开发者 https://www.devze.com 2023-04-11 17:21 出处:网络
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 th

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 heig开发者_如何学JAVAht in IB?

Thanks in advance.


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

  1. 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.

  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号