在我的应用中,我上传了控制器和供稿控制器。
在上传控制器中,图片如下所示: Image Here
在Feed控制器中,图像如下所示: Image here
如您所见,图像被拉伸。那是为什么?
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)
}
我尝试删除sizeForItemAtIndexPath
,这使得图片很合适,但是单元格不适合屏幕:
有什么建议吗?
答案 0 :(得分:0)