可选类型 UILabel 的值未解包

  • 本文关键字:类型 UILabel ios swift
  • 更新时间 :
  • 英文 :


我正在尝试用一个部分和 5 行填充一个表。我得到一个"可选类型 UILabel 的值未解开包装"。我很确定我的语法是错误的或过时的。请指教。

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
        var cell = UITableViewCell()
        cell.textLabel.text = "Hello"
        return cell
    }
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{ 
var cell = UITableViewCell() cell.textLabel!.text = "Hello" 
return cell 
}

当您说单元格未显示"hello"文本时,还有一件事。请检查细胞类型

最新更新