-3

导入 UIKit

类 RightSideViewController:UIViewController,UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate {

var tableView: UITableView!
var textField: UITextField!
var menuItems:[String]=["A","B","C","All"];

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()

// 处理所有可以重新创建的资源。}

@available(iOS 2.0, *)
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
    return menuItems.count;
}

@available(iOS 2.0, *)
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{

    let leftCell = tableView.dequeueReusableCellWithIdentifier("RightCell", forIndexPath: indexPath) as! RightSideTableViewCell
    leftCell.projectsName.text = self.menuItems[indexPath.row]


    return leftCell
}


func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
    let mySelectedCell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!


    // when find checkmark then unchecked

    if mySelectedCell.accessoryType == .Checkmark
    {
        mySelectedCell.accessoryType = UITableViewCellAccessoryType.None
    }
    else
    {
        mySelectedCell.accessoryType = UITableViewCellAccessoryType.Checkmark
        print(menuItems[indexPath.row])

    }

   // when click on "all" deselect all selected checks 
    if indexPath.row == menuItems.count-1
    {
       // i want to deselect my all selected checkmark here
    }




}

}

我无法取消选择单击此处检查

4

1 回答 1

0
于 2015-12-05T14:49:57.163 回答