Search code examples
iosuitableviewswiftuibuttonrow-height

Is there a way to change static cell height with uibutton?


I have UIViewController with static cells in two sections and I want to change height of one row with the button. My only idea was to do something with

 override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    if indexPath.section == 0 && indexPath.row == 0 {
    return 88
    }
    else {
    return 44
    }
}

but I don't think I can assign it to UIButton.


Solution

  • Create a variable for staticCellHeight and return this variable instead of 88

    create an action for UIButton

    change the value of the variable in the action

    call tableview.reloadData()