Ячейки Tableview пусты. Я пробовал несколько раз, и он всегда создает пустые ячейки для моего табличного представления.Ячейки Tableview всегда пусты
Любая помощь пожалуйста? Спасибо.
import UIKit
class GroupsTableViewController: UITableViewController /* UITableViewDataSource, UITableViewDelegate */ {
@IBOutlet weak var table: UITableView!
var items=["Dog","Cat","Cow","Platypus"]
override func viewDidLoad() {
super.viewDidLoad()
self.table.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
self.table.dataSource = self
self.table.delegate = self
// 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()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 0
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return items.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.table.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
cell.textLabel!.text = self.items[indexPath.row]
// Configure the cell...
return cell
}
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
print("You tapped on cell # \(indexPath.row)")
}
'numberOfSectionInTableView' должен быть по крайней мере 1 – Lee
я думал "self.table.dataSource = я" имел в виду, что это было. – O295694
@lee спасибо, я чувствую себя глупо за то, что не обратил внимания. – O295694