In my app, I have upload controller and a feed controller.
In the upload controller the image looks like this: Image Here
In the feed controller the image looks like this: Image here
As you can see, the image is stretched. Why is that?
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell: CollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! CollectionViewCell
cell.layer.borderWidth = 0.75
cell.layer.cornerRadius = 3
let myColor : UIColor = UIColor(red: 0.0, green: 0.0, blue:0.0, alpha: 0.55)
cell.backgroundColor = UIColor.whiteColor()
cell.layer.borderColor = myColor.CGColor
let post = self.arrayOfDetails[indexPath.row]
cell.imageText.text = post.text
cell.uploadedTimeLabel.text = post.CreatedAt.timeAgo
cell.imageView.setImageWithUrl(NSURL(string: post.image)!, placeHolderImage: UIImage(named: "Placeholder"))
return cell
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSizeMake(UIScreen.mainScreen().bounds.size.width - 10, 300)
}
I tried removing the sizeForItemAtIndexPath
, that made the image fits good, but the cell does not fits the screen:
Any suggestions?