Ios UITableHeaderView自动布局中的UILabel不适用于iPhone 6

Ios UITableHeaderView自动布局中的UILabel不适用于iPhone 6,ios,swift,autolayout,uilabel,tableheader,Ios,Swift,Autolayout,Uilabel,Tableheader,我在TableHeaderView中使用UILabel的自动布局。UILabel的高度不是固定的,可能是单行或多行。我在ViewController中对此进行编码: override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() if let headerView = tableView.tableHeaderView { let height = headerView.syst

我在TableHeaderView中使用UILabel的自动布局。UILabel的高度不是固定的,可能是单行或多行。我在ViewController中对此进行编码:

    override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()

    if let headerView = tableView.tableHeaderView {
        let height = headerView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height
        var headerFrame = headerView.frame

        if height != headerFrame.size.height {
            headerFrame.size.height = height
            headerView.frame = headerFrame
            tableView.tableHeaderView = headerView
        }
    }
}
它在iPhone5上运行得非常好。但是,在iPhone6上,当UILabel是单行时,它就会消失

这里是错误日志

    2015-11-22 16:50:42.338 Basket[11898:996678] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x7f97840bd210 h=--& v=--& H:[UIView:0x7f9784072380(375)]>",
    "<NSAutoresizingMaskLayoutConstraint:0x7f97840bd2b0 h=--& v=--& V:[UIView:0x7f9784072380(363.5)]>",
    "<NSLayoutConstraint:0x7f9784032650 UIImageView:0x7f97840705a0.width == 1.33333*UIImageView:0x7f97840705a0.height>",
    "<NSLayoutConstraint:0x7f9784073a40 V:[UILabel:0x7f9784073e90'Funnybeer'(15)]>",
    "<NSLayoutConstraint:0x7f9784128b40 V:[UILabel:0x7f9784128940'Nino Mamaladze'(15)]>",
    "<NSLayoutConstraint:0x7f9784074d10 H:[UIImageView:0x7f97840705a0]-(0)-|   (Names: '|':UIView:0x7f9784072380 )>",
    "<NSLayoutConstraint:0x7f9784074d60 H:|-(0)-[UIImageView:0x7f97840705a0]   (Names: '|':UIView:0x7f9784072380 )>",
    "<NSLayoutConstraint:0x7f9784074e00 V:|-(0)-[UIImageView:0x7f97840705a0]   (Names: '|':UIView:0x7f9784072380 )>",
    "<NSLayoutConstraint:0x7f9784074f40 V:[UIImageView:0x7f97840705a0]-(0)-[UIView:0x7f9784073d20]>",
    "<NSLayoutConstraint:0x7f9784075080 V:[UIView:0x7f9784073d20]-(22)-[UILabel:0x7f9784073e90'Funnybeer']>",
    "<NSLayoutConstraint:0x7f9784075210 V:[UILabel:0x7f9784073e90'Funnybeer']-(3)-[UILabel:0x7f9784128940'Nino Mamaladze']>",
    "<NSLayoutConstraint:0x7f9784075260 V:[UILabel:0x7f9784074300'see you on friday :)']-(0)-|   (Names: '|':UIView:0x7f9784072380 )>",
    "<NSLayoutConstraint:0x7f9784075350 'summary top distance' V:[UILabel:0x7f9784128940'Nino Mamaladze']-(10)-[UILabel:0x7f9784074300'see you on friday :)']>",
    "<NSLayoutConstraint:0x7f9781cf59f0 'tool height' V:[UIView:0x7f9784073d20(44)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7f9781cf59f0 'tool height' V:[UIView:0x7f9784073d20(44)]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-11-22 16:50:42.338篮子[11898:996678]无法同时满足约束条件。
可能下面列表中至少有一个约束是您不想要的。
试试这个:
(1) 看看每一个约束,试着找出你不期望的;
(2) 找到添加了不需要的约束的代码,然后修复它。
(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
)
将尝试通过打破约束进行恢复
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。
我的故事板在这里
有人能帮我吗?

Marco Arment有一个关于如何做到这一点的详细说明。

没有什么可看的,只是可能是因为前两行带有NSAutoresizingMaskLayoutConstraint。是否有任何视图使用自动布局而不将TranslatesAutoResizengMaskintoConstraints设置为NO?我在情节提要中为UILabel添加了约束,只是没有大小的固定。我必须在代码中将UILabel TranslatesAutoResizengMaskintoConstraints设置为NO吗?不,这已经解决了,我想你可以用dasdom的答案来解决它。@RickvanderLinde不幸的是,它不起作用。我的问题不是UILabel resize tableHeaderView,请看我问题中的图片。它不起作用。我说,iPhone5很好用,iPhone6不行。请看我问题中的图片。