我将尝试在Swift中设置自定义UITableViewCell。我已经创建了XIB文件和swift文件。然而,当我运行应用程序时,单元格没有使用我的自定义单元格进行填充,而是完全空白的单元格。
我已经使用以下代码注册了我的单元格:
我已经使用以下代码注册了我的单元格:
self.myTableView.registerClass(customCell.self, forCellReuseIdentifier: "cell")
我还设置了以下内容:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = myTableView.dequeueReusableCellWithIdentifier("cell") as! customCell
cell.descriptionLabel.text = "test"
return cell
}
此外,我已经在自定义单元格中设置了一个指向UILabel的链接。 当我尝试更新它时,应用程序崩溃。 如上所示,代码行为cell.descriptionLabel.text = "test"
。