gpt4 book ai didi

ios - TableView中, "cell.selected = true "这句话后整个表格都不能再点击了

转载 作者:行者123 更新时间:2023-11-28 07:07:47 27 4
gpt4 key购买 nike

cell.selected = true

在这一行之后,我不能再选择行了。有没有人可以帮助我?谢谢

@IBAction func SelectAll(sender: AnyObject)
{
if(selectAll == true)
{


var i = 0 as Int
while(i < indexArray.count){
//indexArray[i] = true



let rowToSelect:NSIndexPath = NSIndexPath(forRow: i, inSection: 0); //slecting 0th row with 0th section
self.tableView(self.selectDownloadTableView, didSelectRowAtIndexPath: rowToSelect);

println(rowToSelect)

i = i+1
}

selectAll = false

creeLigueBouton = UIBarButtonItem(title: "UnSelect", style: UIBarButtonItemStyle.Plain, target: self, action: "creerButtonMethod")
navigationItem.rightBarButtonItems = [creeLigueBouton]
}

else{
var i = 0 as Int
while(i < indexArray.count){
//indexArray[i] = true



let rowToSelect:NSIndexPath = NSIndexPath(forRow: i, inSection: 0); //slecting 0th row with 0th section
self.tableView(self.selectDownloadTableView, didDeselectRowAtIndexPath: rowToSelect);

println(rowToSelect)

i = i+1
}
selectAll = true

creeLigueBouton = UIBarButtonItem(title: "Select", style: UIBarButtonItemStyle.Plain, target: self, action: "creerButtonMethod")
navigationItem.rightBarButtonItems = [creeLigueBouton]
}
}

func creerButtonMethod() {
SelectAll(self)
}


func tableView(tableView: UITableView,didSelectRowAtIndexPath indexPath: NSIndexPath!)
{
selectDownloadTableView.allowsMultipleSelection = true
indexArray[indexPath.row] = true
println("in did select row ")
println(indexPath.row)

var cell : UITableViewCell = self.selectDownloadTableView .cellForRowAtIndexPath(indexPath)!
//cell.selectionStyle = UITableViewCellSelectionStyle.Blue;
cell.contentView.backgroundColor = UIColor.lightGrayColor()
**cell.selected = true**
}

最佳答案

在您的 didSelectRowAtIndexPath 中,您可以在使用 deselectRowAtIndexPath 选择单元格后取消选择它。在您的情况下,它将是:

selectDownloadTableView.deselectRowAtIndexPath(indexPath, animated: false)

或者您可以使用 selectDownloadTableView.reloadData() 重新加载表格

关于ios - TableView中, "cell.selected = true "这句话后整个表格都不能再点击了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29841687/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com