jeudi 25 juin 2015

Hide/show cells in UITableView using swift?

I have create a UITableView in IB. This view contains 5 sections and every section some cells. The first cell in some sections gives the option to the end user to show/hide the rest of the cells that belongs to the same section.

My code so far:

import UIKit

class SettingsVC: UITableViewController {

    @IBOutlet var showCallForwardSwitch: UISwitch?

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func toggleValueChanged(sender: UISwitch) {

        if showCallForwardSwitch!.on {
            println("switch is on")
        } else {
            println("switch is off")
        }

        tableView.reloadData()
    }  
}

So there is only an IBOutlet and an IBAction. I can get the event via the toogleValueChanged func, however I don't know what to do from now on. Which methods to I need to use?

enter image description here

See more ..

Aucun commentaire:

Enregistrer un commentaire