我正在开发我的电子商务应用程序中的第三方宇宙视图。我已经完成了对Cosmos View的显示评级值但是当我滚动Collectionview时我有问题,滚动时间显示评级值会改变。我不明白为什么当我滚动收集视图时,评级值已更改。
有人帮助我吗?
答案 0 :(得分:0)
你可以分享你的" cellForItemAtIndexPath"代码,所以我们可以帮助你。
答案 1 :(得分:0)
我的cellForRow方法
让cellHomeProductCell:CltnHomeProductCell = collectionView.dequeueReusableCell(withReuseIdentifier:“CltHomeProductCell”,for:indexPath)as! CltnHomeProductCell
cellHomeProductCell.setUpBestSellerData(arrModelDataBestSeller: arrBestSellerData)
let dict = arrBestSellerData[indexPath.row] as! [String:AnyObject]
// Rating Value Set
let rate = PIService.getStringFromDict(dict: dict, key: "avg_rating")
print(rate)
let value = Double(rate)
print(value)
if value != nil
{
cellHomeProductCell.ratingView.rating = value!
}
答案 2 :(得分:0)
cellHomeProductCell.setUpBestSellerData(arrModelDataBestSeller:arrBestSellerData)
let dict = arrBestSellerData[indexPath.row] as! [String:AnyObject]
// Rating Value Set
let rate = PIService.getStringFromDict(dict: dict, key: "avg_rating")
print(rate)
let value = Double(rate)
print(value)
if value != nil
{
cellHomeProductCell.ratingView.rating = value!
}else{
print("Found nil value")
cellHomeProductCell.ratingView.rating = 0.0
}