I have three two subviews inside cell contentview. I have height constraint for both of the subviews. Depending on flag I want to hide either of the view. For this i have changed height constraint.
It is not changing the cell height. How can I change the cell height.
Related
I have custom UITableViewCell like this:
Inside UITableViewCell I have UICollectionView, aligned at top with constraints, below it self-made Stepper (view with two Buttons and Label inside), aligned at right by constraints and with fixed width. From the left of UITableViewCell and to the leading of stepper there is an UIImageView, aligned by constraints and also with Aspect constraint (1:1 in preview, i.e. height = width). Stepper's bottom constrained to UIImageView bottom, and also at the bottom of UIImageView another view with Segmented Control and two Labels (named Material). Bottom of UITableViewCell constrained to Material's bottom.
I want to change UIImageView height by changing UIImageView Aspect constraint programmatically (by selecting item in UICollectionView at top) and so height of UITableViewCell, as well as the other bindings, are also changed. For example I want to set Aspect constraint to 2:3 or 4:5, 5:7.
I created IBOutlet for my Aspect constraint inside UITableViewCell class, and try to change it constant in collectionView shouldSelectItemAt method but nothing changes.
What am I doing wrong? I'm new to iOS development, please help me to figure out this issue.
Thanks.
I have tableview inside tableview cell , I am using UITableViewAutomaticDimension in heightForRowAt, tableview height is not adjusting automatically. I have to calculate cell height manually.
Any idea ?
You are missing either bottom or top constraint.
Consider you have to add label in table cell, then you have give both top and bottom constraint to label (make line number 0).
It will automatically increase the size of table cell according to label text.
Don't forgot to set estimatedRowHeight.
To get automatic cell height work correctly you must hook all your constraints properly from top to bottom in the cell Xib , or if you're creating constraints in code , that's how auto-layout can calculate the height automatically
self.tableView.estimatedRowHeight = 50.0
self.tableView.rowHeight = UITableViewAutomaticDimension
Set all constraint like bottom, top, left, right.
I select UITableViewCell with also create xib file.
When I create custom tableViewCell with xib, I see contentView height is 0,5 point less than tableViewCell height.
How do I make the contentView height same to cell height?
I believe the 0.5 is to account for the separator automatically applied to cell in a uitableview.
I have a simple tableview cell with one label (named Bio).
Tableview in storyboard. I want that this label should be change in width according to cell width. e.g. 40% of cell width.
It's easy to do in any view. But can't find the option when I control-drag label to cell content view. The "Equal Widths" is missing. (Also "Equal Heights" missing). Is anything I am missing or its XCode(6.1.1) bug ??
I am trying to set the height of a UITableViewCell based on its children's constraints. Basically, here's the layout:
UITableView > UITableViewCell > NestedUIView (with a computable height)
I started by setting the top, bottom, left, and right constraints of the NestedUIView to be 10px off from the UITableViewCell. Then, I tried adding a height constraint (which in my head would force the UITableViewCell to expand to fit that content. Of course though, it causes a constraint conflict and fails.
This seems like it should be trivial, what am I doing wrong?
Add this to your viewDidLoad method
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 42;
This will tell the table to use the cell constraint's to determine the height.