0

I have to create a screen displaying various activity in the user's account such as picture like, uploading images and videos. Just like this-

1st activity containing picture 2nd activity containing liking

I thought of using custom TableViewCell for which I need to make two different custom cells in a same table view. I had no problem while making a custom cell for the 2nd activity but am facing problem for the first activity as I have to add an UIImageView for the picture and video. The height of view is not increasing along with UIImage added. Can anyone tell me how can I make two different shapes of custom cells or should I use some other way to show the activities?

Termininja
  • 6,620
  • 12
  • 48
  • 49
pri
  • 87
  • 11

2 Answers2

0

You should calculate cell height for different cells. Here is how I do with this:

+(CGFloat)heightForBubbleWithObject:(MessageModel *)object
{
    CGSize retSize = object.size;
    if (retSize.width == 0 || retSize.height == 0) {
        retSize.width = MAX_SIZE;
        retSize.height = MAX_SIZE;
    }else if (retSize.width > retSize.height) {
        CGFloat height =  MAX_SIZE / retSize.width  *  retSize.height;
        retSize.height = height;
        retSize.width = MAX_SIZE;
    }else {
        CGFloat width = MAX_SIZE / retSize.height * retSize.width;
        retSize.width = width;
        retSize.height = MAX_SIZE;
    }
    return 2 * BUBBLE_VIEW_PADDING + retSize.height;
}
Lumialxk
  • 6,239
  • 6
  • 24
  • 47
0

in ios 8 and above put this magical lines and make sure the constraints are properly given

self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 44.0;

there is a wonderful answer about this please refer it for the details Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

Community
  • 1
  • 1
Anshad Rasheed
  • 2,526
  • 1
  • 14
  • 32