【发布时间】:2019-10-06 09:50:41
【问题描述】:
我正在实现 UICollectionView 以在屏幕上加载所有联系信息。保持主线程和后台线程干净,我在 collectionview 上加载数据。现在,一旦加载数据并开始滚动,它就会给我带来极端的帧延迟/抖动。我不确定为什么会这样。我所有的数据源都在后台线程中。
下面是代码:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let data : PhoneContact!
data = allContacts[indexPath.row]
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: friendsCellID, for: indexPath) as! FriendsCell
cell.label.text = data.name
return cell
}
// Cell has only label
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor(rgb: (r: 232, g: 231, b: 222))
setLabel()
}
allContact 有一个 getter,它每次都从电话簿中获取联系人。我想这可能是个问题。但不确定。我可以看看它吗?我想我并没有在考虑什么并最终得出了错误的结果。
【问题讨论】:
标签: ios arrays swift uicollectionview contacts