【发布时间】:2014-09-05 05:09:29
【问题描述】:
我一直在绞尽脑汁想弄清楚这是如何工作的,但我似乎无法理解。我尝试过使用其他教程,但是随着许多 beta 版本的发布,一切都在不断变化。我对 IOS 开发还很陌生,所以我有点挣扎。
在情节提要中,我有 UITableView,它包含一个标识符为“myCell”的单元格。
这是我到目前为止所拥有的。当我运行 IOS 模拟器时,表格视图上没有显示任何内容。
关于如何解决此问题的任何建议?
class ViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) as UITableViewCell
cell.textLabel?.text = "Cell #: \(indexPath.row)" // display the row number
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10; // testing out with 10 cells
}
}
【问题讨论】:
-
你运行的是什么版本的 Xcode?我无法按原样编译。
-
新测试版发布。 Xcode 6 Beta 7。
标签: ios uitableview swift