テーブルビューをスクロールすると、リスト内のバッジが表示されなくなります。右と表示されているスクロールiOSテーブルビューのセル項目がスクロールすると消えます
import UIKit
class CustomTableViewCell: UITableViewCell {
@IBOutlet weak var badgeIcon: AsyncImageView!
@IBOutlet weak var title: UILabel!
func configureCell(data: JSON) {
if let itemType = data["item_type"].int, itemTitle = data["item_type"].string {
title.text = itemTitle
if itemType == 1 {
badgeIcon.hidden = true
} else {
badgeIcon.hidden = false
}
}
テーブルビュー
私のtableViewは、最初にすべてをロードし
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("myCustomCell") as! CustomTableViewCell
let data = items[indexPath.row]
cell.configureCell(data)
//Dont show highlight
cell.selectionStyle = UITableViewCellSelectionStyle.None
return cell
}
:
マイセルはCustomTableViewCell
CustomTableViewCellのカスタムクラスを持つように設定されていますbadg
badgeIcon.hidden = true
この:EICONはとprepareForReuseをオーバーライドし、それがあるべき場所を表示/非表示されているが、私は/上下にスクロールあれば数回はbadgeIconは常にあなたのUITableViewCell
サブクラス内
カスタムセルクラス内にバッジを追加して、クラスitemtypeに送信してください。 cell.itemType = 1、デフォルトではfalseのままにします。 – Anton
バッジのデフォルトの動作を追加する必要があります。たとえば、let itemType = ..の前にbadgeIcon.hidden = falseを入力してください。 –
'configureCell'はどこから呼び出されますか? 'cellForRowAtIndexPath'関数を表示できますか? – Paulw11