【问题标题】:How to adjust the height of my tableView when my dropdown menu is clicked?单击下拉菜单时如何调整tableView的高度?
【发布时间】:2019-07-07 10:32:28
【问题描述】:

我在我的 UITableView 上方实现了一个下拉菜单,当我点击它时,我希望我的表格视图进入我的下拉菜单的项目中,因为现在当我点击我的下拉菜单时,表格视图留在原处..

我的原型单元格上方有一个视图,其中包含我的下拉菜单,但我不能对其施加任何限制...当我单击“过滤器”时,我希望发生这种情况:image description here

【问题讨论】:

    标签: ios swift uitableview drop-down-menu


    【解决方案1】:

    看起来您添加了一个表头视图。它与常见的 UIView 有点不同。

    与其改变Height约束,不如改变headerview的frame

    how-to-set-the-height-of-table-header-in-uitableview

    此外,您可以从这些链接中找到很好的下拉实现代码。 https://github.com/qmathe/DropDownMenuKit

    https://github.com/onmyway133/Dropdowns

    【讨论】:

    • 哦,是的,我明白了,但你知道我需要更改什么属性才能使此标题视图在屏幕上从较低或较高的位置开始吗?
    • 让 headerView = tableView.tableHeaderView! let height = headerView.systemLayoutSizeFitting(UILayoutFittingCompressedSize).height var frame = headerView.frame frame.size.height = height headerView.frame = frame tableView.tableHeaderView = headerView 可以在viewDidlayoutsubviews方法上调用这个方法。
    猜你喜欢
    • 2015-03-14
    • 2020-10-26
    • 1970-01-01
    • 2021-09-29
    • 2021-06-15
    • 2016-06-14
    • 2019-05-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多