0

I've created UITableView programmatically, but it doesn't show any separators. When I run the project I can see on Debug View Hierarchy that it exists, but i cannot understand why i cannot see it on simulator? Any of you knows what I'm missing or what is wrong with my code?

I'll really appreciate your help.

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
// Proerties


var tableView: UITableView!

override func viewDidLoad() {

    super.viewDidLoad()

    tableView = UITableView(frame: view.bounds)
    tableView.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
    tableView.dataSource = self
    tableView.delegate = self
    tableView.rowHeight = 100
    tableView.separatorColor = UIColor.redColor()
    tableView.separatorStyle = .SingleLine
    tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
    view.addSubview(tableView)
}

//     UITableViewDataSource

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 5
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) 
    let row = indexPath.row
    cell.textLabel?.text = String(row)
    return cell
}


//     UITableViewDelegate

func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        cell.backgroundColor = UIColor.cyanColor()



}

}

birdy
  • 943
  • 13
  • 25

0 Answers0