From 0d7d97db57c09b5b34d82a233c0eeed8c97f419d Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Thu, 16 Jun 2016 01:42:24 +0300 Subject: [PATCH] update readme --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2933cde..71eae3a 100644 --- a/README.md +++ b/README.md @@ -124,11 +124,11 @@ class StringTableViewCell: UITableViewCell, ConfigurableCell { } } ``` -It's enough for most cases. But you may not be happy with this. So you could use +It's enough for most cases. But you may be not happy with this. So you could use a prototype cell to calculate cell's heights. To enable this feature simply use this property: ```swift tableDirector.shouldUsePrototypeCellHeightCalculation = true ``` -It does all dirty work with prototypes behind the scene, so you don't have to worry about anything except of your cell configuration: +It does all dirty work with prototypes for you behind the scene, so you don't have to worry about anything except of your cell configuration: ```swift class ImageTableViewCell: UITableViewCell, ConfigurableCell { @@ -138,10 +138,16 @@ class ImageTableViewCell: UITableViewCell, ConfigurableCell { loadImageAsync(url: url, imageView: imageView) } } + + override func layoutSubviews() { + super.layoutSubviews() + + contentView.layoutIfNeeded() + multilineLabel.preferredMaxLayoutWidth = multilineLabel.bounds.size.width + } } ``` -As you can see you don't have to load any remote images to your cell, cause it's not visible. It's a prototype cell, just to calculate apropriate height. - +First of all you have to set `preferredMaxLayoutWidth` for all your multiline labels. And check if a configuring cell is a prototype cell. If it is, you don't have to do any additional work that not actually affect cell's height. For example you don't have to load remote image for a prototype cell. ## Installation