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

如果没有用autoLayout的话,那返回的高度都会是0. #19

Closed
kingslay opened this issue May 21, 2015 · 2 comments
Closed

如果没有用autoLayout的话,那返回的高度都会是0. #19

kingslay opened this issue May 21, 2015 · 2 comments

Comments

@kingslay
Copy link

//解决办法就是在获取高度之后判断一下,是否为空,如果为空的话,那就用cell的高度设置一下就可以了。
CGSize fittingSize = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
if (fittingSize.height == 0) {
fittingSize.height = cell.frame.size.height;
}

@sunnyxx
Copy link
Member

sunnyxx commented May 22, 2015

1.2 版本还不支持非 auto layout 的布局方式,且约束连的不对时会返回 0 让开发者注意约束的错误,不过新版本中对于 frame 布局的 cell 增加了 -sizeThatFits:的调用,重载这个方法后可以返回希望的高度。你所说的 fittingSize.height = cell.frame.size.height; 并不能解决问题,因为 template layout cell 只是为了计算,不会显示到屏幕上,且计算的结果也不会设置给这个 cell。请留意接下来新版本的更新,谢谢。

@sunnyxx
Copy link
Member

sunnyxx commented May 27, 2015

Fixed in 1.3

@sunnyxx sunnyxx closed this as completed May 27, 2015
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

2 participants