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

How to get rid of AutoLayout warning when using TableKit #89

Open
bernikovich opened this issue Jan 21, 2019 · 5 comments
Open

How to get rid of AutoLayout warning when using TableKit #89

bernikovich opened this issue Jan 21, 2019 · 5 comments
Labels

Comments

@bernikovich
Copy link

Hello.
How should I implement constraints to get rid of these warnings. I see it comes when table view requests cells for index path:
screen shot 2019-01-21 at 5 05 56 pm
I setup cells like subview.top == cell.contentView.top, subview.bottom == cell.contentView.bottom.

@maxsokolov
Copy link
Owner

Hey @bernikowich

First of all, let's make sure that this is not a problem with TableKit itself. Do you have this warning with regular UITableView setup (without TableKit)?

I setup cells like subview.top == cell.contentView.top, subview.bottom == cell.contentView.bottom.

Are you sure that you have all required constraints? What about leading/trailing (left/right) constraints?

@bernikovich
Copy link
Author

bernikovich commented Jan 21, 2019

@maxsokolov Looks like I found where my issue comes from. I should say I create UI in code. So I implemented such controller in the demo project. In this case if minimum height of cell is more then 44 OS prints warning logs.
Steps:

  1. Create cell in code with constraints subview.top = contentView.top + 25 and subview.bottom = contentView.bottom - 25.
  2. Set estimatedHeight for cell 100 - it should be enough since 25+25=50<<<100.
  3. TableDirector receives cell with height 44 for the first time.

screen shot 2019-01-21 at 6 29 17 pm

4. When `layoutIfNeeded` called we have constraint for height equal to 44, while it cannot be satisfied because our minimum height for `contentView` is 50.

@bernikovich
Copy link
Author

Screenshot I attached previously is incorrect. I should attach screenshot from TablePrototypeCellHeightCalculator. When TablePrototypeCellHeightCalculator dequeues cell it has default height. For cells created in code it's 44.

@bernikovich
Copy link
Author

Looks like it related more to UIKit itself. I don't know why UITableView dequeues cell for indexPath with 44pt height and not estimated height. When you use IB it creates cells with bigger size.

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

No branches or pull requests

2 participants