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
5
votes
2 answers

UITableView dynamic cell height conflict - height NOT depending on a label

So, my table view displays images. Every cell is basically an image filling out the cells entire contentView. As the images come with different aspect ratios, I need my cells to be adjusting their height depending on the table views width and the…
Percolator
  • 513
  • 5
  • 25
5
votes
3 answers

iOS: Dynamic Height For UITableViewCell

I'm using iOS9 XCode7 I need to change the height of cell Dynamically according to labelText Height I have used: self.tableView.rowHeight=UITableViewAutomaticDimension; But it is not working for custom made cell. sizetoFit is removed in…
Ankit
  • 638
  • 1
  • 8
  • 10
5
votes
2 answers

Detecting double and single tap on UITableViewCell to perform two action

I have a PFQueryTableViewController in which I am trying to learn some tableView interactions. What I currently have: The tableView cell increases its height on a tap didSelectRowAtIndexPath or I can basically segue cell related data to next…
5
votes
2 answers

Wrong UITableViewCell height for some cells at first loading

I am using UITableViewAutomaticDimension to calculate height for my table view cell. It works fine for me. But for some cells, the height returned is 44 rather than dynamically calculating height. But on scrolling up an looking back to the same…
4
votes
1 answer

While scrolling resize the custom Table cell height with UITableViewAutomaticDimension as per downloaded image height

I am getting the image's URL at run time and  download & display these images in a table. Images are  downloading asynchronously(using SDWebImage). What is more important is that I want to display all these images with their actual sizes. First time…
4
votes
1 answer

UITableView: Scrolling to the bottom with custom/variable cell heights is inaccurate on the initial scroll

Edit: https://streamable.com/rfym will show it in action. The first time I press Scroll To Bottom, it doesn't get all the way to the bottom. I then manually get all the way to the bottom and quickly scroll all the way back up. Once I press Scroll To…
David
  • 7,028
  • 10
  • 48
  • 95
4
votes
1 answer

iOS > 8: issue with UITableViewAutomaticDimension and layoutIfNeeded

Based on this SO post I updated my TableViewControllers to always call layoutIfNeeded after populating my custom tableviewcells. In fact this is the only way to have the cells render correctly with multiple multiline labels. The cells now render…
t0day
  • 121
  • 8
3
votes
1 answer

UIView-Encapsulated-Layout-Height constraint issue in Table View

class ViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() // https://stackoverflow.com/a/27148268/14016301 tableView.estimatedRowHeight = 2.0 …
3
votes
1 answer

UIStackView with multiline label in a UITableViewCell incorrect height

I have a table view where each cell displays an optional title and a multiline subtitle. I want the cell to be self-sizing (i.e grow along with the subtitle but stay as compact as possible). For that I use tableView.rowHeight =…
Jan
  • 7,444
  • 9
  • 50
  • 74
3
votes
5 answers

UITableViewAutomaticDimension works not as expected. Swift

After reading Ray Wenderlich guide for "Self-sizing Table View Cells" as well as this question and answers to it, I've decided to ask all of you for a help. Have a programmically created cell: import UIKit class NotesCell: UITableViewCell { lazy…
3
votes
1 answer

Table view "jumps" when I try to scrollToRow with UITableViewAutomaticDimension. The fix also makes it jump

I have the same issue as this one. I have tried to implement a suggested fix, and instead of a table view going the whole way up and then going to the last row again, I got the small jumps up. I need to make the animations smoother. Can it be done…
sash.tsvet
  • 71
  • 8
3
votes
1 answer

iOS 11: Adapt cell size to content with UITableViewAutomaticDimension

I want the cells of a UITableView to adapt to the size of their content in iOS 10 and 11 with: tableView.estimatedRowHeight = UITableViewAutomaticDimension // default in iOS 11 tableView.rowHeight = UITableViewAutomaticDimension Without setting the…
Manuel
  • 14,274
  • 6
  • 57
  • 130
3
votes
4 answers

Nib-file loaded UIView in UITableViewCell does not stretch

I have a UIView which is reusable via a nib/xib-file. I want to load this and fill a UITableViewCell which is to be used in a self-resizing UITableView. All with auto-layout. Most works good, but It seems as the loaded UIView uses the added…
Sunkas
  • 9,542
  • 6
  • 62
  • 102
3
votes
1 answer

UITableViewCell Automatic Row Height not working after asynchronous call

I have successfully made my custom uitableviewcell to work with automatic dimension. In my custom cell, I have a label (used to display captions, can be one line or multilines) and an imageview. Auto-layout is set correctly and I specified estimated…
Carl Pan
  • 99
  • 3
  • 6
3
votes
5 answers

scrollToRowAtIndexPath always scrolls from the top instead from current offset

In my UITableView I use a method to scroll to the last cell: WLNetworkClient.sharedClient().createCommentWIthText(commentTextView.text, forItem: item) { error in defer { UIAlertController.showAlertFromError(error) } if error ==…
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
1
2
3
9 10