【问题标题】:UITableView Custom Cell iPhone Using Swift languageUITableView 自定义 Cell iPhone 使用 Swift 语言
【发布时间】:2014-09-04 08:53:09
【问题描述】:

我正在尝试使用 Swift 语言在自定义表格视图单元中分配文本。但它给出了错误说明“致命错误:在展开可选值时意外发现 nil”

http://i.stack.imgur.com/333xS.png

【问题讨论】:

  • 您的名字 TableVIew 中有一个大的“i”。对吗?
  • 是的,这是正确的。在 Swift 中,“DequeueReusableCellWithIdentifier”函数不支持除“func tableView(tableView:UITableView!, cellForRowAtIndexPath indexPath:NSIndexPath!) -> UITableViewCell!”函数之外的其他自定义函数

标签: uitableview swift


【解决方案1】:

不应该有错误。检查标识符字段中输入错误的标识符。

【讨论】:

    【解决方案2】:

    您可能应该使用以下 UITableView 数据源方法中的代码行。您的代码应如下所示:

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    
    var cell: BlogTableCell! = tableVIew.dequeueReusableCellWithIdentifier("BlogTableCell") as! BlogTableCell
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      • 2012-02-16
      相关资源
      最近更新 更多