Hey guys. Cut to the chase. Trynna create some cells in my CollectionView. Cells will populate with the object of type Tweet.
Some Tweet(s) has urlToExpand, some has value nil. Based on that, button "See more" will be visible or nah. I am certain that the data is passed correctly into Cell as I have checked it with the print. However button works randomly. Sometimes it does display, sometimes it doesn't. I have no idea why.
Here is my dataSource update in VC
Here is the function from collectionViewCell that I am calling in my cv while populating cells.
Many thanks for any help.
Some Tweet(s) has urlToExpand, some has value nil. Based on that, button "See more" will be visible or nah. I am certain that the data is passed correctly into Cell as I have checked it with the print. However button works randomly. Sometimes it does display, sometimes it doesn't. I have no idea why.
Here is my dataSource update in VC
Code Block private func configureDataSource() { dataSource = UICollectionViewDiffableDataSource<Section, Tweet>(collectionView: collectionView, cellProvider: { (collectionView, indexPath, tweet) -> UICollectionViewCell? in let cell = collectionView.dequeueReusableCell(withReuseIdentifier: SearchTweetsCell.reuseId, for: indexPath) as! SearchTweetsCell cell.set(with: tweet, user: self.user) cell.delegateSafari = self return cell }) dataSource.supplementaryViewProvider = { (collectionView, kind, indexPath) in let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: SearchTweetsVCCollectionHeader.reuseId, for: indexPath) as! SearchTweetsVCCollectionHeader header.set(with: self.user) return header } }
Here is the function from collectionViewCell that I am calling in my cv while populating cells.
Code Block func set(with usersTweet: Tweet, user: User) { self.user = user tweet = usersTweet urlString = usersTweet.urlToExpandWithSafari tweetBodyLabel.text = usersTweet.tweetText timeDateLabel.text = usersTweet.createdAt.formatToTwitterPostDate() sharesView.set(itemInfoType: .shares, with: usersTweet.retweetCounter.convertToKMFormatStr()) likesView.set(itemInfoType: .likes, with: usersTweet.likesCounter.convertToKMFormatStr()) guard tweet.urlToExpandWithSafari != nil else { DispatchQueue.main.async { self.goSafariButton.removeFromSuperview() } goSafariButton.isEnabled = false return } DispatchQueue.main.async { self.goSafariButton.setTitle(TweetStrings.seeFull, for: .normal) } }
Many thanks for any help.