Ich nahm eine UIViewController
. Dann brachte ein TableView
hinein. Und dann ein TableViewCell
in der Tabellenansicht. Ich habe identifier
und benutzerdefinierte Tabellenansicht-Zellklasse mit dieser Prototyp-Zelle zugewiesen. Hat auch notwendige Steckdosen geschaffen. Dann ist dies meine Elternansicht Controller:UITableView zeigt keine Daten an?
class MyViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var theTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// let cell = MyTableViewCell()
// cell.optionText = UILabel()
// cell.optionText?.text = "testing..."
// theTableView.addSubview(cell)
theTableView.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
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) as! MyTableViewCell
cell.optionText.text = "hello..."
return cell
}
}
Aber mein Tisch ist leer. Was vermisse ich?
Sie meinen, anders als 'theTableView.dataSource = self'? – NSNoob
Oh mein Schlechter :) ... –