【问题标题】:Getting fatal error: unexpectedly found nil while unwrapping an Optional value [duplicate]出现致命错误:在展开可选值时意外发现 nil [重复]
【发布时间】:2017-10-26 05:23:52
【问题描述】:

MapPinAnnotation 是我定义的MKAnnotation 类型的一个类

var lblNotificationCount:UILabel!

我想在标签处设置文本,但出现如下错误:-

let storeAnnotation = annotation as! MapPinAnnotation

并且在控制台中我能够获得计数值,但它打印错误如下:-

控制台输出:

Count: 1
fatal error: unexpectedly found nil while unwrapping an Optional value

请帮助,如何解决这个问题。提前致谢。

【问题讨论】:

  • .text = String(count) ... 试试
  • @cerberus,不工作。

标签: swift3 uilabel mapkit mkannotationview


【解决方案1】:

这可能会有所帮助:

storeAnnotation.lblNotificationCount.text = String(describing: count)

【讨论】:

  • 仍然出现同样的错误。不工作。
  • 检查 IBOutlet 的标签。
猜你喜欢
  • 2014-08-29
  • 2016-01-26
  • 1970-01-01
  • 1970-01-01
  • 2016-02-29
相关资源
最近更新 更多