I am trying to pop up date picker inside a static cell and I get this compiler error. Any thoughts?
The error is on line: "return super.tableView(tableView, heightForRowAtIndexPath: indexPath)"
import UIKit
class TableViewController: UITableViewController {
@IBOutlet weak var detailLabel: UILabel!
@IBOutlet weak var datePicker: UIDatePicker!
var datePickerHidden = false
override func viewDidLoad() {
super.viewDidLoad()
datePickerChanged()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
@IBAction func datePickerValue(_ sender: UIDatePicker) {
datePickerChanged()
}
func datePickerChanged () {
detailLabel.text = DateFormatter.localizedString(from: datePicker.date, dateStyle: DateFormatter.Style.short, timeStyle: DateFormatter.Style.short)
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.section == 0 && indexPath.row == 0 {
toggleDatepicker()
}
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if datePickerHidden && indexPath.section == 0 && indexPath.row == 1 {
return 0
}
else {
return super.tableView(tableView: tableView, didSelectRowAtIndexPath: indexPath)
}
}
func toggleDatepicker() {
datePickerHidden = !datePickerHidden
tableView.beginUpdates()
tableView.endUpdates()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
How should I fix this issue?