Questions tagged [uitableviewautomaticdimension]

UITableViewAutomaticDimension is a constant value that can be assigned to UITableView's rowHeight property to enable mechanism of automatic cell's height calculation. Use this tag in questions about self-sizing table view cells. Related tags are [tag:uitableview], [tag:tableviewcell] and [tag:autolayout]

Useful information about self-sizing table view cells can be found at the Apple's documentation. Basic steps are the following:

tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 85.0

Also, in each table view cell you need an unbroken chain of constraints and views (with defined heights) to fill the area between the content view’s top edge and its bottom edge. If your views have intrinsic content heights, the system uses those values. If not, you must add the appropriate height constraints, either to the views or to the content view itself.

estimatedRowHeight property could be emitted if you have table view's delegate and have implemented -tableView:estimatedHeightForRowAtIndexPath: method to return own value for each row. This method should be lightweight enough to have minimal impact for main thread efficiency. Here you still can return UITableViewAutomaticDimension constant.

140 questions
2
votes
2 answers

How to prepareForReuse on a UITableView with auto-layout?

I have have a UITableView with cells of automatic dimension using auto-layout. In addition, all of the subviews of the cells are using auto-layout (programmatic constraints). Since these cells and their corresponding subviews have uniquely different…
Rage
  • 870
  • 9
  • 27
2
votes
2 answers

Self-sizing tableview cell with only imageView

I'm struggling with the following problem: I have a TableViewController in which every cell has only an imageView. It uses autolayout to cell's contentView's margins and it is set to aspectFit. What I want is the height of cell to size accordingly…
Daniel Z.
  • 458
  • 1
  • 3
  • 23
2
votes
1 answer

How to create UI using autolayout which will have expand collapse feature in Swift?

I have a UI to design I need to create this UI using AutoLayout and i am confused shall i use only UITableViewCell to create this UI or i have to create this using `Section. Also how will i work with expand collapse could someone help me in…
2
votes
2 answers

Make tableview cell expand with textView text size

For this i studied many tutorial But I was not able to find solution for my problem I want to show textView's on table cell. and Cell should expand with the text entered by user in the textView. As I found there are two ways to do this first one:-…
Parv Bhasker
  • 1,773
  • 1
  • 20
  • 39
2
votes
0 answers

iOS 11 UITableView bug with automatic sectionHeaderHeight can cause glitchy animations and leave broken sections on top of tableview

Whilst developing my latest app I would occasionally experience a rendering problem with my tableview where it appeared that my tableview cells weren't given enough space to fit in each section. I struggled to reliably reproduce the issue until…
2
votes
1 answer

Resizing UITableView to fit content on ios 11

Given the junk contentSize in UITableView on ios 11 how to I get a tableview with variable height cells to autosize to that content? Answers here: Resizing UITableView to fit content have rotted and no longer apply to ios 11
Anton Tropashko
  • 5,486
  • 5
  • 41
  • 66
2
votes
1 answer

Manage automatic header height with dynamic label width in UITableView

I want to create a UITableView header with dynamic height. I have four labels in the view and the height of the header must be adjusted according to the content in each of the UILabels. I want to achieve something similar to this image. Sample…
2
votes
2 answers

UITableViewAutomaticDimension is making empty cells too big

I'm making a TableView with UITableViewAutomaticDimension but for some reason the "extra" blank cells after the last one are the same dimensions as the last cell with text in it. I want the blank cells to all be a smaller size unless filled with…
Bob F.
  • 93
  • 1
  • 11
2
votes
0 answers

How to get a correct automatic row height calculation when modifying the layout inside a UITableViewCell's layoutSubviews() method?

I have a UITableView with cells that are variable in height, laid out with Auto Layout in Interface Builder (rowHeight = UITableViewAutomaticDimension). When the user rotates the device I perform some manual layout changes inside the cell that…
Mischa
  • 15,816
  • 8
  • 59
  • 117
2
votes
1 answer

Swift - How dynamically fixed UITableViewHeaderFooterView height size?

I have just tried below lines of code, but I doesn't work correctly. I wonder that how can I provide this case for header or footer programmatically, may be using autolayout I don't know exactly which one solved my problem. I'm using xib file both…
iamburak
  • 3,508
  • 4
  • 34
  • 65
2
votes
1 answer

Detail Label in "Left Detail" style cell text getting cut off- swift

I have a table view controller with a prototype cell with style "Left Detail." -In my viewDidLoad() I have self.tableView.estimatedRowHeight = 40 and self.tableView.rowHeight = UITableViewAutomaticDimension like many solutions have said to do.…
Tessa
  • 176
  • 13
2
votes
1 answer

UITableViewRowAnimationAutomatic with UITextView does not show up correctly

On iOS 9, to set up my tableView with UITableViewAutomaticDimension and a 200.f estimatedRowHeight on viewDidLoad. [self.tableView setEstimatedRowHeight:200.f]; [self.tableView setRowHeight:UITableViewAutomaticDimension]; It works well for cells…
2
votes
2 answers

UITableView with automatic dimension do no display cells properly. Always the LAST label within that cell is sometimes broken

Simple case: Some of my cells are displayed randomly with proper way or not: this is a good way: this is not a good way. What it depends on, and how to fix it? Interesting thing: I added at the end another label: and now that last label…
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
2
votes
1 answer

Dynamically set the height of UITableViewCell to wrap content

I'm trying to display 3 image views, along with some additional information in a UILabel, in a UITableView. Attached is an image of my Cell Prototype: Currently, my issue is that the image content is running over to the following cell. As I test,…
2
votes
5 answers

dynamic cell height in ios using constrain programatically in swift

I am working on a project in swift which needs the cell size to be dynamic according to the label content, so i searched for dynamic cell height, i found some solution but all of it included use of storyboard for assigning constrain. Is it possible…
1 2
3
9 10