Reputation: 393
I would greatly appreciate it someone could help me with the syntax for calling super
to get the UITableViewCell
from within func tableView (tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!)
. This is a static table.
override func tableView (tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
// The Objective-C code is: UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
var cell = super.??
}
I have tried and tried, but cannot seem to get the correct syntax for doing this. Thanks in advance.
Upvotes: 9
Views: 4385
Reputation: 115
In Swift 4 and ios 10+
oneCellOutlets.IsHidden = true
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let cell = super.tableView(tableView, cellForRowAt: indexPath)
if cell.isHidden == true
{
return 0
}
else{
return super.tableView(tableView, heightForRowAt: indexPath)
}
}
Upvotes: 0
Reputation: 6805
var cell = super.tableView(tableView, cellForRowAt: indexPath)
Upvotes: 16
Reputation: 9649
What it worked to me was.
let cell = someController.tableView.cellForRow(at: NSIndexPath(row: item, section: 0) as IndexPath)
Upvotes: 1
Reputation: 148
Update for Swift 3:
var cell = super.tableView(tableView, cellForRowAt: indexPath)
Upvotes: 3