【发布时间】:2014-10-02 06:17:19
【问题描述】:
我已经四处寻找这个问题的答案,但没有任何成功。我基本上是按照教程来创建一个简单的待办事项应用程序,许多其他人都在评论与以下相同的错误。作者还没有解决办法。任何帮助,将不胜感激。
我收到错误:'UITableViewCell?'没有名为“textLabel”的成员
到目前为止,这是我的代码:
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
// tells iphone what to put in each cell
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 4
}
// Tells iphone how many cells ther are
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
cell.textLabel?.text = "table cell content"
return cell!
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
【问题讨论】:
-
您必须创建一个 UITableViewCell 类型的 customCell 文件...然后在该 customCell 文件中制作标签的 IBOutlet 然后您就可以使用它...
标签: ios uitableview swift tableview