4

I'm trying to make app like Instagram and I'm stuck on feed screen.

I made comment part as UITableView. So I have UITableView in my UITableView's custom cell class. Thats ok.

My question is: How can I change main feed table view's height from my custom table view cell class?

Comment table view's row height is dynamically changing according to text(length) inside of it. Dynamic variable is comment table view's height that I plan to use.

Note: I cannot share any code because it is confidential project for our company.

Cheers

enter image description here

Gokhan Gultekin
  • 291
  • 5
  • 15

2 Answers2

2

Ideally, you should use Autolayout to adjust a UITableViewCell's height for a particular row in your UITableView. There is a Stackoverflow thread which discusses this in detail.

Community
  • 1
  • 1
indyfromoz
  • 4,045
  • 26
  • 24
0

Use the tableView delegate method heightForRowAtIndexPath to set the height of the tableViewCell

– (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

Use the boundingRectWithSize method to find the height of the dynamic comment label section and add the other static content height in the tableviewcell and set this height in the above delagate method.

- (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options context:(NSStringDrawingContext *)context
krisrak
  • 12,882
  • 3
  • 32
  • 46