現在、関連するviewControllerに含まれる特定のUILabelsを取り除くために、UITableViewのセルをループしています。セル内のテキストを編集するために、UITableView内の個々のUITableViewCellsをループする
どうすればいいですか?
コンテキスト:配列specialBoolには6個のboolが含まれています。インデックスの位置は、特別なものかそうでないものかに対応しています。ブールが真であれば、その特定の製品セルのラベル(previousPrice)を打ち切りたい。もしそれが偽ならば、ラベルは正常のままでなければならない。
これは、これまでの私のコードです。それは不完全です:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! exploreTableView
cell.photo.image = globalVariable.images[indexPath.row]
cell.name.text = globalVariable.names[indexPath.row]
cell.price.text = globalVariable.prices[indexPath.row]
cell.unitPrice.text = globalVariable.unitPrice[indexPath.row]
cell.pPrice.text = globalVariable.previousPrice[indexPath.row]
var i = 0
while i < globalVariable.previousPrice.count {
if (globalVariable.specialBool[i] == true) {
// Strike through previous price
let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: globalVariable.previousPrice[i])
attributeString.addAttribute(NSStrikethroughStyleAttributeName, value: 2, range: NSMakeRange(0, attributeString.length))
cell.pPrice.attributedText = attributeString;
} else {
cell.pPrice.text = globalVariable.previousPrice[i]
}
i += 1
}
return cell
}
コードの関連部分を画像ではなくテキストとして質問に追加してください。 – JAL