0
이것이 가능한지는 확실하지 않지만 특정 기준이 충족되는 경우에만 CollectionView cellForItem을 사용하여 셀을 반환하려고합니다.UICollectionViewCell은 특정 기준이 충족 될 때만 표시됩니다.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FriendsRecentCell", for: indexPath) as! FriendsRecentCell
var fObj = PFObject(className: FRIENDS_CLASS_NAME)
fObj = recentArray[indexPath.row]
// Get User Pointer
let userPointer = fObj[FRIENDS_IS_FRIEND_WITH] as! PFUser
userPointer.fetchIfNeededInBackground(block: { (user, error) in
if error == nil {
// Get heys sent to you as currentUser
let query = PFQuery(className: HEYS_CLASS_NAME)
query.whereKey(HEYS_RECEIVER, equalTo: PFUser.current()!)
query.whereKey(HEYS_SENDER, equalTo: userPointer)
query.countObjectsInBackground { (count, error) in
if count != 0 {
// Get User fullname
cell.userLabelRecent.text = "\(userPointer[USER_FULLNAME]!)"
// Get Avatar
cell.avatarImageRecent.image = UIImage(named: "avatar")
cell.avatarImageRecent.layer.cornerRadius = cell.avatarImageRecent.bounds.size.width/2
let imageFile = userPointer[USER_AVATAR] as? PFFile
imageFile?.getDataInBackground(block: { (imageData, error) in
if error == nil {
if let imageData = imageData {
cell.avatarImageRecent.image = UIImage(data:imageData)
}}})
} else {
}}
}})
return cell
}
난 단지 셀 if count != 0
을 반환하려면 :
여기 내 기능입니다. 이 일을 할 수있는 방법이 있습니까? 나는 완전히 잃어 버렸다.
이 데이터를 모두 사전 처리하여 배열에 넣은 다음 collectionView를로드하는 것이 좋습니다. 관심이 있다면 내일지도를 좀 더 제공 할 수 있습니다. – toddg
예 내일 도움이 필요합니다. @toddg –