小编nou*_*ouf的帖子

UICollectionView动态单元格高度(Pinterest布局)

我正在尝试在我的应用程序中实现Pinterest布局

我使用以下委托方法来实现它并动态设置单元格高度

 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
    let boundingRect =  CGRect(x: 0, y: 0, width: self.view.frame.size.width / 2 - 20, height: CGFloat(MAXFLOAT))
    let data = articles[indexPath.row]
    let rect  = AVMakeRect(aspectRatio: (data.coverImage?.size)!, insideRect: boundingRect)
    return CGSize(width: rect.width, height: rect.height + 120) // Added 120 for a description I will add later 
}
Run Code Online (Sandbox Code Playgroud)

但是我得到了以下结果:

这里

灰色背景是单元格的背景,你可以看到每个单元格都有自己的高度(正如预期的那样),但是还有额外的空格,我不知道如何删除.

我怎样才能解决这个问题?

pinterest uicollectionviewcell swift

9
推荐指数
1
解决办法
7115
查看次数

Swift 3 - 两个字典数组之间的差异

我有两个字典数组:

let arrayA = [["name1": "email1"], ["name2": "email2"]]
let arrayB = [["name1": "email1"], ["name3": "email3"]]
Run Code Online (Sandbox Code Playgroud)

我想比较它们并得到另外两个数组:arrayC应该有arrayA中的元素而不是arrayB中的元素,而arrayD应该有arrayB中的元素而不是arrayA中的元素:

let arrayC = [["name2": "email2"]]
let arrayD = [["name3": "email3"]]
Run Code Online (Sandbox Code Playgroud)

如何考虑大型阵列呢?

arrays comparison dictionary swift

5
推荐指数
2
解决办法
3869
查看次数