Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10.3 自适应不行了 #289

Closed
JWXIAN opened this issue Mar 28, 2017 · 21 comments
Closed

10.3 自适应不行了 #289

JWXIAN opened this issue Mar 28, 2017 · 21 comments

Comments

@JWXIAN
Copy link

JWXIAN commented Mar 28, 2017

No description provided.

@JWXIAN
Copy link
Author

JWXIAN commented Mar 28, 2017

12a1e78d556d6d39734e42c90ac506cf

@Er01c
Copy link

Er01c commented Mar 28, 2017

@JWXIAN
Copy link
Author

JWXIAN commented Mar 28, 2017

这是自适应失效了?

@KenmuHuang
Copy link

+1,希望能自适应处理好 10.3 系统下使用 Masonry 约束的高度计算

@apascual
Copy link

Same problem here...

@apascual
Copy link

I found the problem...

It looks like for some UILabel, a preferredMaxLayoutWidth is configured, mainly when they are created using the Storyboard/NIB file. And the problem is that the value available at the time that the Cell is created is the one it had on the Storyboard...

Setting all the label's preferredMaxLayoutWidth to 0 fixed the problem for me, i.e.:

self.labelnsideCell.preferredMaxLayoutWidth = 0;

@apascual
Copy link

Or even better:

self.labelnsideCell.preferredMaxLayoutWidth = self.frame.size.width;

@yudun1989
Copy link

yudun1989 commented Mar 29, 2017

https://github.com/yudun1989/UITableView-FDTemplateLayoutCell/commit/b300c2eaad4dbfd6524919f38aad3f130e776649

暂时给contentView加上了上下左右的约束

10.3在调用systemLayoutSizeFittingSize的时候会多添加几条width和height的约束,导致约束冲突

@tyrad
Copy link

tyrad commented Mar 29, 2017

我现在的解决办法是在awakeFromNib中计算出label的实际宽度,并赋值给label.preferredMaxLayoutWidth(我的cell是用xib写的)

@faimin
Copy link

faimin commented Mar 29, 2017

归根结底还是得设置多行labelpreferredMaxLayoutWidth属性,我的设置好之后就正常了

@HomerLi
Copy link

HomerLi commented Mar 29, 2017

问题: 项目中使用 XIB 布局, 单个 cell 对应 单个view, 第一次打开带 多行 label 的 cell 时, 布局正常. 再打开其他的带多行 label的 cell 时, 自动布局失效,即行高计算错误.
解决方法:
目前 设置 label 的 preferredMaxLayoutWidth 在我的项目中不起作用
我的解决方法是 在 awakeFromNib 中填加如下代码:

[self layoutIfNeeded];
self.noteLabel.lineBreakMode = NSLineBreakByWordWrapping;(此行只在有多行 label 的 cell 视图中添加)

lineBreakMode 枚举中, 选择前三个任意一个, 布局正常.
PS: 当打开一个行高计算错误的 cell 后, 之后打开的 cell 继续计算错误. 所以需要将所有用到缓存行高的 cell (包括没有多行 label 的 cell) 全部修改,即 不会再出现计算错误的情况下, cell 显示正常.

@13hoop
Copy link

13hoop commented Mar 29, 2017

10.3
systemLayoutSizeFittingSize自动有width和height约束
导致约束冲突

使用preferredMaxLayoutWidth 设置时注意

@LynahZ
Copy link

LynahZ commented Mar 29, 2017

纯代码项目中,使用Masonry和FD自适应cell高度,也出现一样的问题,这种情况应该怎么解决呢,每个cell都对应设置一下preferredMaxLayoutWidth

@FreshAlpha
Copy link

FreshAlpha commented Mar 29, 2017

重新约束contentView
self.contentView.mas_remakeConstraints { (m: MASConstraintMaker!) in
m.edges.equalTo()(self)
}
并且在cell的xib中更改cell的width为较大值。
测试有效。

@taogeyijiu
Copy link

taogeyijiu commented Mar 29, 2017

楼主看到你的帖子,我赶紧看了一下我的界面,iOS10.3没有发现问题呀,好多人都说设置preferredMaxLayoutWidth, 我也没设置过呀,不知道你的问题出在哪里???我也是用的纯代码+ Masonry

@yudun1989
Copy link

@taogeyijiu 用nib布局会出问题

@xiongoahc
Copy link

+1

@xiongoahc
Copy link

设置多行label的preferredMaxLayoutWidth就好啦

@afantree
Copy link
Member

结论: 多行label的preferredMaxLayoutWidth的问题

@zidonJ
Copy link

zidonJ commented Oct 31, 2017

I resolve this use a estimatedRowHeight and set a value not zero. It is very helpful.

@pusswzy
Copy link

pusswzy commented Nov 22, 2018

I resolve this use a estimatedRowHeight and set a value not zero. It is very helpful.

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests