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
1
vote
0 answers

Left or right align shouldShowMenuForRowAt menu for a custom UITableView cell

I have a UITableView that I am using for showing chat messages. The cells of this table view are either left or right-aligned and have dynamic width. The menu displayed by shouldShowMenuForRowAt is shown at the horizontal center of the table view…
Parth
  • 2,682
  • 1
  • 20
  • 39
1
vote
2 answers

Table View with the cells having fixed height and dynamic height

I have a single tableview with multiple sections. In 1st section I want 4 tableview cells with fixed height whereas in all other sections I want tableview cells with dynamic height. The Problem is that when I am populating the table view the dynamic…
1
vote
0 answers

UITableViewCell contentView subview breaks AutoLayout constraints

I am creating table view (code-only) private lazy var tableView: UITableView = { let tableView = UITableView() tableView.dataSource = self tableView.translatesAutoresizingMaskIntoConstraints = false tableView.register(MyCell.self,…
1
vote
2 answers

Wrong height with automatic sizing tableView

Scenario I am using the automaticDimension option on UITableView. I'd like to have a single UILabel in my cell that is self-sizing to fit the text. Setup Here you can see how I setup the label. The edges are equal to the contentView…
Josh
  • 504
  • 3
  • 14
1
vote
2 answers

Make tableview cell height dynamically after download image from server

I have one cell in which i show images download from server now. Right now i show image with static height but now i want to make dynamic like facebook and instagram. For example if i upload image 320 * 100 then my cell need to become 300*100. and…
Chirag Shah
  • 3,034
  • 1
  • 30
  • 61
1
vote
2 answers

How to Iterate through all UITableView sections?

I'm trying to convert a UITableView with multiple section and dynamic rows. I'm currently trying to loop through all the subviews of a UITableView. I'm trying to insert each subview into a container UIView where I could combine them all to make up a…
1
vote
0 answers

Adjust Table View Cell custom view constraint after image loaded from url

In my application, I have a uitableview whose cell height is measured by autolayout UITableViewAutomaticDimension. The cell contains an image, whose height is adjusted by a NSLayoutconstraint outlet connected to cell. Image is loaded from a URL.…
1
vote
0 answers

self sizing table view with different constraint

i am trying to make self sizing table view. the table view cell before editing is like this there are 2 type of post in this table view cells. a post without image, and a post with an image. I want to make that second post 'Testting' which is only…
Alexa289
  • 8,089
  • 10
  • 74
  • 178
1
vote
1 answer

Inconsistent spacing between grouped sections

When a section in a grouped UITableView contains both header text and footer text, the spacing between that section and one above it becomes inconsistent with the rest of the table view. To make sure this wasn't developer error (or an Xcode project…
1
vote
3 answers

UILabel height depending on font size

I am using a UILabel in a UITableViewCell to display a title. Normally the text is not too long and therefore the font size can be large. Notice how the text fills the height of theUILabel like normal. However, when there is a larger title, I want…
1
vote
1 answer

Adding new row to a tableview with dynamic height cells

I have a table view with cells having dynamic height. I want to add a new row on a button click. I am incrementing the number of rows in section value and reloading the table view.But this results in a crash.I tried this after commenting the…
user7887716
1
vote
3 answers

UITableView with rowHeight UITableViewAutomaticDImension does not update when I change the number of lines

I have a UITableViewCell with a description label pinned to the bottom as shown below: Tapping on the description label toggles the numberOfLines between 3 and 0: - (void)awakeFromNib { [super awakeFromNib]; [self setupView]; } -(void)…
W.K.S
  • 9,787
  • 15
  • 75
  • 122
1
vote
2 answers

Hiding UI elements in UITableViewCell and resize cell according

What is the best approach to hide UI elements in a UITableView with UITableViewAutomaticDimension? I have multiple labels, buttons, imageviews in a cell. For specific condition I want to hide some of them and want the tableview to resized…
Ankit Kumar Gupta
  • 3,994
  • 4
  • 31
  • 54
1
vote
0 answers

Programmatically adding constraints to UITableCellView

In my project targeting iOS 8 I have a UITableView with automatic, variable row height. In the storyboard I have defined one prototype UITableViewCell with most constraints set up. Since the cell content can vary slightly based on the object it's…
1
vote
1 answer

Rows all same height after using UITableViewAutomaticDimension

I'm trying to make all the rows in my table have their own row height based on the lines of text in the label in that cell. My point of departure is the Wenderlich Tutorial here: https://www.raywenderlich.com/129059/self-sizing-table-view-cells I'm…