Rightpoint / RZCellSizeManager

Dynamic size computation and caching for cells.
MIT License
242 stars 32 forks source link

iPhone 6 / iPhone 6+ width issue #26

Open cerupcat opened 9 years ago

cerupcat commented 9 years ago

I have cell nib files that are 320 with autolayout. They correctly scale to the correct with on iPhone 6/6+. However, the calculation of height seems to be based on 320 instead of the iPhone 6/6+ width. I've tried setting overrideWidth to the width of iPhone 6/6+ but that doesn't seem to change anything.

What's the correct process for calculating the correct height using a single nib for iPhone 5, iPhone 6, and iPhone 6+?

zhubofei commented 9 years ago

You can use self.tableView.rowHeight = UITableViewAutomaticDimension in iOS8

jwardle commented 9 years ago

I'm experiencing the same issue - I've overridden the width to the iPhone 6/6+ widths with no effect. I also have set the above rowHeight property and estimatedHeight.

Using RZCellSizeManager the height of my cells are often (sporadically...) too tall, leading to height variable UILabels expanding to fill the size making the cell layout malformed.

Removing the use of RZCellSizeManager and resorting to default iOS auto layout cell height calculation (without caching) renders all cells with the correct height, but obviously suffers from jumpy scrolling without the caching.

I have set the preferredMaxLayout on the labels, and also removed it with the same effects...

Suggests that the RZCellSizeManager is using the wrong width (inherited from the NIBs? Mine are iphone 5 sized...at 320pts), and with overrideWidth not having an effect it makes the library unusable.

jwardle commented 9 years ago

After wrangling with this for a while, I've found that the easiest way to support iPhones 5 / 6 / 6+ resolutions is to use:

var cellSize = cell.contentView.systemLayoutSizeFittingSize(CGSizeMake(self.tableView.bounds.width, 0.0), withHorizontalFittingPriority: 1000.0, verticalFittingPriority: 50.0)

To ensure the cell fills out to the size of the view it is contained in. Using the following always constrains the cell to the smallest size based on constraints, both vertically and horizontally, which in some cases depending on your constraints could lead to a tall + narrow 'frame' leading to exaggerated heights...

var cellSize = cell.contentView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize)

I've used the first code snippet in a custom heightBlock to work around this issue.

phaibin commented 9 years ago

Same issue, iPhone6 has no perfect height. Please fix this!

jwardle commented 9 years ago

phaibin, use the snippet of code I posted above in a custom sizeBlock - works fine for me as a work around. Works across all device resolutions so far.