チェックしたセルでテーブルビューを読み込み、特定のセルのチェックを外したい場合は、セルを2回タップしてチェックを外す必要がありますが、どのように私はこの問題を解決することができますか?テーブルセルのチェックを外すには2回タップする必要があります
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("daySelected", forIndexPath: indexPath)
cell.selectionStyle = .None
cell.textLabel?.text = days[indexPath.row]
if indexPath.row == 0 && day[0] == true{
cell.accessoryType = .Checkmark
}
return cell
}
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if let cell = tableView.cellForRowAtIndexPath(indexPath) {
cell.accessoryType = .Checkmark
}else{
cell!.accessoryType = .None
}
if indexPath.row == 0{
day[0] = true
}
}
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
if let cell = tableView.cellForRowAtIndexPath(indexPath) {
cell.accessoryType = .None
}
if indexPath.row == 0{
day[0] = false
}
}
あなたがチェックマークのためのつもりなら、あなたはおそらくでセルの選択を解除する必要があり、これは私の問題を解決しますが、それだけで新しいものを作成し、私はセルをチェックボックスをオンまたはオフにしたいとき、今、私は二回 – User
をタップする必要がありますメソッドの終わり(素晴らしいハイライトアニメーションが得られるように) - 私はそのコードで私の答えを更新しました。 – sschale
あなたは素晴らしいです:) – User