I have a TableViewController
and want to change the height
of one of my Static Cells when I press a Button. I created an Outlet of my Cell:
@IBOutlet var myCell: UITableViewCell!
The problem is, that I don't have a property height, so that I can so s.th. like this:
@IBAction func btnClick(sender: UIButton) {
myCell.rowHeight = 200
}
I know that there is a method called:
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
...
}
But how can I trigger this method when I press my UIButton?
tableView.beginUpdates()
followed by tableView.endUpdates()
triggers the call of delegate methods like tableView:heightForRowAtIndexPath:
so you could do something like that:
var height = 100
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return height
}
@IBAction func btnClick(sender: UIButton) {
tableView.beginUpdates()
height = 200
tableView.endUpdates()
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.