2017-11-20 19 views
-2

私はEコマースアプリケーションでサードパーティのコスモスビューを作成しています。既に完了しています。コスモスビューに表示された値を評価しましたが、私はcollectionviewをスクロールしたときにRating Valueが変更された理由を理解できません。評価値が間違っているコレクションを表示表示

誰でも手伝ってください。

答えて

0
  • 各セルごとにcellForItemAtIndexPathに正しい値を渡してください。問題はif/else tableview再利用可能なセルのように思えます。
  • if else条件をすべて確認し、すべての値を常に割り当てます。

「cellForItemAtIndexPath」コードを共有すると、お手伝いできます。

+0

私は今、私のCellForRowの問題が解決され –

0

マイcellForRow方法

ましょうcellHomeProductCell:CltnHomeProductCell = collectionView.dequeueReusableCell(withReuseIdentifier: "CltHomeProductCell"、用:indexPath)など! 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! 
     } 
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 
    } 
+0

上cellForItemAtIndexPathメソッドを追加しました。ありがとうございますRahul_Chandnani –

+0

ようこそ。 ifとbothの両方の条件に値を割り当てる必要があることを常に覚えておいてください。 –

関連する問題