1

I am building a simple iOS application using Swift.

One of my views, displays a list of comments (cells in a PFQueryTableViewController...I am using Parse.com for my database).

My cells resize happily in order to fit the possible multiple-lines of the comments. This is MAGIC! (if you ask me)

What I am having trouble doing, is making the UIView which is at the top of the TableView resize based on multiple lines worth of content for the Label in that top view (see below).

enter image description here

Instead of doing multiline and resizing the view (I have set up constraints and set lines of text to 0), the label only shows one line, truncating it at the edge of the screen with "..."

Does anyone have any suggestions or solution for how to cause my top UIView to resize based on the content of the UILabel?

I was also thinking this could maybe better be done using a Container View at the top of the TableViewController?

Max
  • 1,974
  • 2
  • 16
  • 24
  • 1
    Just as a note, the method with the least lines of code is not always the best solution. Code can still be unreadable and difficult to maintain even if it's only one line – Luke May 25 '15 at 13:44
  • fixed :) still looking for solution/answer – Max May 25 '15 at 13:46

1 Answers1

0

There is a delegate method in UITableViewDelegate that lets you return the height of the head view (heightForHeaderInSection). You have to implement it making sure you return the proper height.

If you have a nib with constraints already, you can load the nib in a @property, and use the method systemLayoutSizeFittingSize that should give you enough height.

For more details checkout this post I wrote a while ago: Customize the UITableview with different height of cells like Facebook feeds in iOS

Community
  • 1
  • 1
Pauls
  • 2,596
  • 19
  • 19