last day (20 days later) » 

11:29 PM
0
Q: UITableView auto resizing row constraint breaking mysteriously on iPhone 6Plus

suparngpI have a custom UITableViewCell which has a thumbnail and bunch of text. The row height is configured to be calculated automatically using tableView.estimatedRowHeight = 129; tableView.rowHeight = UITableViewAutomaticDimension The row height should be calculated as exactly 168 points. Everyt...

 
can you post the code which calculates the height of the cell?
 
I am using the tableView.estimatedRowHeight = 129; tableView.rowHeight = UITableViewAutomaticDimension to calculate the row height in viewDidLoad of my controller.
 
still, if it is fully dynamic there should be no error. Even if it is not exactly 168. Are you implying that your views inside the cell are set up in such a way that if you add up all of their height it is exactly 168?
 
The thumbnail is configured to be 20 points from the top left and bottom edge of my cell. And the thumbnail height itself is 108 points. Adding up all the spaces and the thumbnail height equals 168. Atleast thats what I expect the dynamic row height to be.
 
Does it display wrongly? And what about text labels? I assume they are embedded in a UIView. Do you set its height or is it calculated from the height of labels inside?
 
11:29 PM
Yes everything displays fine both iPhone 5 and 6 plus. And the logs that I posted appear only in iPhone 6 Plus. Despite of the logs, everything appears fine on the screen. But since the constraints break, every time my debugger pauses.
The text labels are aligned with the top and bottom edge of the thumbnail. They are not in a UIView. I am adding them directly on tableViewCell.
 
can you please send screenshot of your view setup from IB
 
There you go.
 
thank you!
 
The Top tile, Avani Villas is aligned with top edge of the thumbnail.
 
can you please tell me what sort of constraints you have (in a vertical direction) for
Avani villas
20m away
Beachfront..
San Francisco
 
11:36 PM
Avani Villas, top edge aligned with the thumbnail, Leading Space 18
 
just vertical ones
:)
 
20 m - 8 from Avani Villas
 
Beach Front - 15
 
from 20m?
 
11:38 PM
Yes
and San Francisco aligned to the bottom of the thumbnail.
 
there is no constraint between San Francisco and Beachfront?
 
Sorry. the San Francisco is 2 pts from Beach Front. Its NOT aligned to the bottom of the thumbnail.
My bad.
 
is it aligned to the bottom of the view?
or is it free to float?
 
No only the thumbnail is aligned to the bottom.
 
wow
is there any chance you can upload a source code? Maybe create a dummy app with just this view controller to test prototype cells
I'll tell you what my idea was
0.333 is not a strange offset
on iPhone 6+ the screen is something like 2.7 times denser. Still, it is treated as @3x
so 0.333 is basically 1 pixel off somewhere
 
11:41 PM
Owwww!
This might be the case. This is actually a part of a fairly complicated app, It would be hard to get the source code out.
 
can you copy this prototype cell to a dummy project?
just one view controller, one table view, this cell in the storyboard and nothing else?
I thought that you had a vertical alignment between your labels which determined the height of your cell. And because they have text they could report slightly different value depending on what the text was.
so, for some cases it would report 168.333
 
Its the thumbnail that decides the height of the cell.
 
actually, can you clarify one more thing please
 
Give me a minute to copy over the cells.
 
when the height is different, do you have a message about braking constraints?
 
11:45 PM
The height is always the same, because I am trying to design it with sample data only. So all the rows are completely alike.
 
However, for certain rows the constraints break reporting that the height is 168.333 and it breaks the Thumbnail height constraint.
 
wow
then copy your cell
I want to have a look at it.
different height wouldn't be a huge problem
but I see no reason for braking constraints
 
Sorry to bulge in, but did I understand correctly that you have a height constraint on your image view and also top and bottom constraints on it?
 
If I adjust the height manually by using systemLayout... it gives a height of exactly 168 and everything works fine, But then other things start falling apart.
Yes thats correct.
Top 20, Bottom 20, ImageView 128
ImageView height 128.
 
11:50 PM
what is the size of your actual image? is It exactly 384?
 
Not its not exact. It is scaled to fit.
 
Do all the constraints have the same priority?
 
Yes, they all have the default priority.
 
What is the contentMode on your image view?
 
Center.
 
11:51 PM
Could you check after decreasing the priority for the image view height constraint to, for example, 900?
 
hi guys
how r u ?
 
try setting content mode to .AspectFit.
I wonder if this issue might be due to the fact that it calculates wrong height for image view based on the size of the actual png
 
No its the same thing with setting the AspectFit.
The image view has a height of 128.
 
what if you set image that is used to nil? SO it doesn't display any picture
what happens in this case?
 
The same error. I set the image of the imageView to nil.
Hi mahleddine!
 
11:55 PM
Try @Losiowaty suggestion. Decrease priority of the constraint
 
IT WORKED!!!!
 
i have a little question guys if you can help me out it will be great
 
The calculated height is still coming out to be 168.333
But I no longer get the warning about breaking the constraints.
 
0
A: Custom UIViewControllerContextTransitioning and black screen

hsafaryaTry to set modalPresentationStyle of the presenting view controller to UIModalPresentationCustom

 
Well, don't get your hopes, as the breaking still happens "under the hood" :)
 
11:59 PM
I think I can mark my question as answered. Thanks @An
And @Losiowaty
 

  last day (20 days later) »