添加子视图后,UITableViewCell contentView框架大小是否会自动增加 [英] does a UITableViewCell contentView frame size increase automatically after adding subviews
本文介绍了添加子视图后,UITableViewCell contentView框架大小是否会自动增加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
添加子视图后,UITableViewCell contentView框架的大小是否会自动增加?
does a UITableViewCell contentView frame size increase automatically after adding subviews?
假设您:
- 在UITableViewCell内容视图中添加一些子视图(例如UILabel)
- 然后使用label.frame = CGRectMake(...方法 设置UILabel的大小/位置
- 然后UITableViewCell的框架大小会自动更改以适应此情况-即,如果您转到tableViewCell.contentView.frame.size.height,这应该是仅适合子视图所需的总高度吗?
- add a few subview (e.g. UILabel's) to the UITableViewCell content view
- then set the UILabel size/position using the label.frame = CGRectMake(... approach
- then is the UITableViewCell's frame size change automatically to accommodate this - i.e. if you go tableViewCell.contentView.frame.size.height should this be the total height required to just fit in the subviews?
推荐答案
我不这样认为.您可以通过UITableView属性rowHeight或实现UITableViewDelegate方法来设置单元格的框架高度
I don't think so... That doesn't seem logical really. You set the frame height for your cells via UITableView property rowHeight or by implementing UITableViewDelegate method
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
这篇关于添加子视图后,UITableViewCell contentView框架大小是否会自动增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文