Reputation: 11107
In my cellForRowAtIndexPath
method I have the following code.
var cell = tableView.dequeueReusableCellWithIdentifier("Media Item", forIndexPath: indexPath) as MediaItemTableViewCell
let mediaItem = tweet!.media[indexPath.row]
let imageData = NSData(contentsOfURL: mediaItem.url)
if imageData != nil {
cell.mediaImage = UIImage(data: imageData!)
} else {
cell.mediaImage = nil
}
return cell
When I run this code my image overlaps over the TableViewCell
.
I would love to have the image become thumbnail size and not overlap the bounds of the TableViewCell. What would be the best way to approach this? I've tried resizing the image but the image still becomes clipped. Thanks.
Upvotes: 0
Views: 758
Reputation: 241
in my opinion the different dynamic image sizes worked by adding NSAutoLayoutConstraint
s to it relative to its height and width , you might face another problem that image is not centred correctly due to its size , which could be fixed by adding a proprtional NSAutoLayoutConstraint
programtically to it then if you ever faced.
Upvotes: 0
Reputation: 2093
Have you marked aspect-fit in the UIImage and clipSubviews on MediaItemTableViewCell class in interfaceBuilder? (Attached image).
Upvotes: 1