OGeek|极客世界-中国程序员成长平台

标题: ios - UITableView 页脚、 Storyboard 和 Xcode 6 的自动布局问题 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 14:19
标题: ios - UITableView 页脚、 Storyboard 和 Xcode 6 的自动布局问题

我正在尝试通过 Storyboard 向我的 UITableView 添加页脚 View ,但 Autolayout 不断绘制的页脚 View 比我在 Storyboard 中调整 View 的大小要大得多。这似乎是由页脚 View 中包含的 UIButton 上的自动布局约束引起的,尽管没有任何约束组合(我已经尝试了几个)导致页脚 View 大小正确,即使我在页脚中正确调整了 UIButton 大小查看。

问题截图(页脚 View 为白色背景):imgur link

我在这个特定实例中使用的约束(尽管请记住,我已经尝试了几个,包括那些为 UIButton 定义了高度的约束 - 当我设置 UIButton 的高度时 UIButton 正确绘制,但页脚 View 仍然由于某种原因巨大):

constraints

想法?解决方案?在使用 Storyboard 之前,我已经将页脚 View 与 Storyboard 一起使用,没有任何问题,尽管从来没有使用大小类。



Best Answer-推荐答案


希望这会有所帮助:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)

    var footerView  = self.tableView.tableFooterView! as UIView
    var frame       = footerView.frame

    frame.size.height = 30
    footerView.frame = frame

    self.tableView.tableFooterView! = footerView
}

关于ios - UITableView 页脚、 Storyboard 和 Xcode 6 的自动布局问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28551941/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4