我正在尝试使用DECLARE @id varchar(10)='u3'
SELECT Id, Subject,
CASE WHEN (',' + UsersWhoLiked + ',') LIKE '%,'+@id+',%' THEN 1 ELSE 0 END Liked
FROM Post
创建一个类别列表,因为我们可以看到有一个棕色圆圈实际上是CollectionView
(可设计的背景视图)。
我想将背景颜色从棕色更新为随机颜色。但是随机颜色仅在我向上滚动并向下滚动UIView
后显示,就像这里的.gif文件一样:http://g.recordit.co/BxRf26Uw2t.gif
向上和向下滚动后,颜色会更新,但有些项目仍然是棕色,如下所示:
这是我的CollectionView
ViewController
这是import UIKit
import ChameleonFramework
class FacilitiesVC: UIViewController {
@IBOutlet weak var collectionVIew: UICollectionView!
struct StoryBoard {
// Collection View
static let indoorFacilitiesCategoryCellIdentifier = "indoorFacilitiesCell"
static let numberOfColumnsPerRow : CGFloat = 3.0
static let inset: CGFloat = 10.0
static let spacing: CGFloat = 8.0
static let lineSpacing: CGFloat = 8.0
//segue Identifiers
}
var indoorFacilitiesCategoryData = [FacilitiesCategory]()
var outdoorFacilitiesCategoryData = [FacilitiesCategory]()
override func viewDidLoad() {
super.viewDidLoad()
getIndoorOutdoorFacilitiesData()
}
}
extension FacilitiesVC {
func getIndoorOutdoorFacilitiesData() {
let facilitiesData = FacilitiesCategoryLibrary.fetchFacilitiesCategory()
// distinguishing between indoor and outdoor data
for facData in facilitiesData {
if facData.type == "Indoor Facility" {
indoorFacilitiesCategoryData.append(facData)
} else {
outdoorFacilitiesCategoryData.append(facData)
}
}
}
}
extension FacilitiesVC : UICollectionViewDataSource {
// MARK: - UICollectionViewDataSource
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return indoorFacilitiesCategoryData.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: StoryBoard.indoorFacilitiesCategoryCellIdentifier, for: indexPath) as! IndoorFacilitiesCell
cell.indoorFacilitiesCategoryData = indoorFacilitiesCategoryData[indexPath.item]
cell.designableBackgroundView.backgroundColor = RandomFlatColor()
cell.layer.borderColor = UIColor.lightGray.cgColor
cell.layer.borderWidth = 1
return cell
}
}
CollectionViewCell
这里出了什么问题?我该怎么做才能解决这个问题?