在TableView中,在句子“cell.selected = true”之后,整个表格不再单击

时间:2015-04-24 07:49:18

标签: ios swift tableview

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**
    }

1 个答案:

答案 0 :(得分:1)

didSelectRowAtIndexPath deselectRowAtIndexPath中,您可以在使用selectDownloadTableView.deselectRowAtIndexPath(indexPath, animated: false) 选择单元后取消选择单元格。在你的情况下,它将是:

selectDownloadTableView.reloadData()

或者您可以使用tf history /collection:"http://server:8080/tfs/Collection" "$/Project" /recursive /stopafter:1 /noprompt /login:domain\user,password

重新加载表格