Expand & Collapse

Hi


How to create expand/collapse in Table View Cell


Company Policy Plus Sign

Terms & Conditions Plus Sign


When user press Plus Sign then it should change to - sign & display the text.

Then if user presses - sign then it should collapse.


Thanks

Hello. I am having the same issue also. I submitted some of my code to support. When I hear from them for I have userful information that works. I will let you know.

What about having a textField that will be:

- hidden when collapsed

- visible (and filled) when expanded.


You should also compute the cell height accordingly in

optional func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat

Hi Claude31


Can u provide little help with code


Thanks

Can you show how you defined your cellView class ?

It must have a UITextField or a label, a button


In the view controller, you have tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int)

it should lokk like :

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier("SignalisationCell", forIndexPath: indexPath) as? MyCell
        if (cell == nil) {
            cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "MyCellIDentiifier") as? MyCell
        }

         // put the content from dataSource in the textField of the cellView
        // depending on the status of the button, hide the textField: cell!.textField.hidden = true or false
        return cell!
    }
Expand & Collapse
 
 
Q