2

I'm writing an application where images are downloaded asynchronously and when the images are loaded its scaled but I just want to show as the same size within the UITableViewCell.

Since i'm using auto layout I have tried to change the height constraint through an IB but then I have to change the height of the cell and I though of reloading each cell after downloading each image but not sure if it's a good idea.

Its like the Facebook application where images are loaded and the uitableviewcell is dynamically changed.

Imran Hishaam
  • 141
  • 1
  • 10

1 Answers1

1

Have you tried this delegate method?:

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        // return downloadedimage.bounds.height etc.
    }

Also do not forget to reload data in the viewDidLoad method

tableView.reloadData()
IamMashed
  • 1,811
  • 2
  • 21
  • 32
  • I tried the problem is that the images are downloaded asynchronously so i don't exactly know what the actual size of the image is and each image is downloaded while scrolling so i cant reload the table after each image is downloaded – Imran Hishaam May 08 '15 at 11:39
  • try reloading data in viewDidLayoutSubviews() – IamMashed May 08 '15 at 11:51