Qusai Hussain Qusai Hussain - 1 year ago 136
iOS Question

Cannot call value of non-function type 'UITableView

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() {
// 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) {

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 {

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



override func didReceiveMemoryWarning() {
// Dispose of any resources that can be recreated.

How should I fix this issue?

Answer Source

Assuming that you're calling this inside a UITableViewController class. Well, UITableViewController has a property called tableView. So when you start off with super.tableView, it thinks you're asking for the property, which is why it gives the error that tableView is of non-function type.

See if return super.tableView.rowHeight works for your case.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download