为什么在修改其帧高度时仅接受非零值?
谁能告诉我为什么UaiteView的tableheaderview
属性仅接受非零值?
我正在尝试修改我的uitableview的tableheaderview
用于缩小上限的属性的高度值。
以下是我接近的方式。
设置uitableview中表格的高度属性值为0实际上会删除上部边距
但是在应用以下代码时,没有任何更改。
//UIView has the tableView property for its one of sub views
tableView.tableHeaderView = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 0, height: 0)))
我在网上搜索了这一点,发现了一些 从苹果参考 似乎TableHeaderview属性仅接受其修改的非零值。 因此,我只是将高度设置的值设置为
cgfloat.leastnormalmagnitude
,它只是有效的。
tableView.tableHeaderView = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 0, height: CGFloat.leastNormalMagnitude)))
我很好奇的是,我仍然无法承受为什么零值和最小值
值有所不同。 设置帧高度值不应该为0实际删除屏幕上的Uiview吗?
Can anyone tell me why UITableView's tableHeaderView
property only accepts non zero value?
I'm trying to modify the height value of my UITableView's tableHeaderView
property for narrowing upper margin.
Below is the way I approached.
Setting the height property value of tableHeaderView in UITableView as 0 would actually remove the upper margin
However, nothing has changed when applying the code as below.
//UIView has the tableView property for its one of sub views
tableView.tableHeaderView = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 0, height: 0)))
I searched online about this and found some
explanation from apple reference
It seems like tableHeaderView property only accepts non zero value for its modification.
So I just set the value for height setting as CGFloat.leastNormalMagnitude
and it just worked.
tableView.tableHeaderView = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 0, height: CGFloat.leastNormalMagnitude)))
The point I'm curious about is that I still cannot undertstand why zero value and leastNormalMagnitude
value make difference.
Shouldn't setting frame height value as 0 actually remove the UIView on screen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从我在Apple doc 中看到的:
没有为什么。就是这样。
From what I see in Apple doc :
There is no why. It is just like this.