用mansard对cell的子控件设置约束,并且自动计算cell高度的问题,ios7警告
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用mansard对cell的子控件设置约束,并且自动计算cell高度的问题,ios7警告相关的知识,希望对你有一定的参考价值。
mansory设置cell子控件自上而下把cell的contentview撑开,就计算可以自动计算高度了,但是ios7会报下面的警告
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)
(
"<MASLayoutConstraint:0x179e9210 UILabel:0x1673d3d0.height == 14.316>",
"<MASLayoutConstraint:0x1670dd90 UILabel:0x1673d3d0.top == UITableViewCellContentView:0x179d32e0.top>",
"<MASLayoutConstraint:0x1798e460 UIView:0x179df8e0.top == UILabel:0x1673d3d0.bottom + 10>",
"<MASLayoutConstraint:0x179d57b0 UIView:0x179df8e0.bottom == UITableViewCellContentView:0x179d32e0.bottom - 25>",
"<NSAutoresizingMaskLayoutConstraint:0x178c4980 UITableViewCellContentView:0x179d32e0.height == 44>"
)
最后后一句话是说原有的44默认约束和现有的有些冲突,解决办法是
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
if (self)
{
self.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;//**这句话很重要
[self createSubViews];
}
return self;
}
http://stackoverflow.com/questions/19132908/auto-layout-constraints-issue-on-ios7-in-uitableviewcell
以上是关于用mansard对cell的子控件设置约束,并且自动计算cell高度的问题,ios7警告的主要内容,如果未能解决你的问题,请参考以下文章
IOS 通过 代码 自定义cell(Cell的高度不一致)(优化性能)