I am trying to create a custom table view cell from the tip. I mean this article here . I ran into two problems.
I created a .xib file with a UITableViewCell object that was ported to it. I created a subclass of UITableViewCell and set it as the cell class, and Cell as the reusable identifier.
import UIKit class CustomOneCell: UITableViewCell { @IBOutlet weak var middleLabel: UILabel! @IBOutlet weak var leftLabel: UILabel! @IBOutlet weak var rightLabel: UILabel! required init(coder aDecoder: NSCoder!) { super.init(coder: aDecoder) } override init(style: UITableViewCellStyle, reuseIdentifier: String!) { super.init(style: style, reuseIdentifier: reuseIdentifier) } override func awakeFromNib() { super.awakeFromNib()
In the UITableViewController, I have this code,
import UIKit class ViewController: UITableViewController, UITableViewDataSource, UITableViewDelegate { var items = ["Item 1", "Item2", "Item3", "Item4"] override func viewDidLoad() { super.viewDidLoad() }
This code is error free, but when I run it in the simulator, it looks like this.

In the UITableViewController in the storyboard, I did nothing with the cell. An empty identifier and no subclass. I tried to add the cell id to the prototype cell and run it again, but I get the same result.
Another error that I encountered is when I tried to implement the following method in a UITableViewController.
override func tableView(tableView: UITableView!, willDisplayCell cell: CustomOneCell!, forRowAtIndexPath indexPath: NSIndexPath!) { cell.middleLabel.text = items[indexPath.row] cell.leftLabel.text = items[indexPath.row] cell.rightLabel.text = items[indexPath.row] }
As shown in the above article, I changed the form of the cell type of the UITableViewCell type to CustomOneCell , which is my subclass of UITableViewCell. But I get the following error:
Overriding method with the selector 'tableView: willDisplayCell: forRowAtIndexPath:' has an incompatible type '(UITableView !, CustomOneCell !, NSIndexPath!) → ()'
Does anyone know how to resolve these errors? They seemed to work fine in Objective-C.
Thank.
EDIT: I just noticed if I changed the orientation of the simulator to the landscape and returned it to the portrait, the boxes will appear! I still could not understand what was happening. I downloaded the Xcode project here , demonstrating the problem if you have time to quickly browse.