大佬教程收集整理的这篇文章主要介绍了ios – Swift UITableViewCell detailTextLabel.text抛出错误’致命错误:无法解包Optional.None’,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
if (cell == nil) { println("1") cell = UITableViewCell(style: .Subtitle,reusEIDentifier: "CellSubtitle") //cell = tableViewCell }
永远不会被调用,因此永远不会使用UITableViewCellStyle.Subtitle样式初始化单元格.以下是该方法所需的代码:
func tableView(tableView: UITableView!,cellForRowATindexPath indexPath: NSIndexPath!) -> UITableViewCell! { println("start TableViewCellForRowATindexPath") var cell: UITableViewCell! = tableView.dequeueReusableCellWithIdentifier("CellSubtitle") as UITableViewCell if (cell == nil) { println("1") cell = UITableViewCell(style: UITableViewCellStyle.Subtitle,reusEIDentifier: "CellSubtitle") //cell = tableViewCell } cell.textLabel.text = instructions[indexPath.row].text println("2") //cell.detailTextLabel cell.detailTextLabel.text = "HI" println("3")
start load 1 2 done load start TableViewCellForRowATindexPath 2 Fatal error: Can't unwrap Optional.None (lldb)
如何初始化detailTextLabel以插入文本?当我尝试设置标签的文本时,我收到致命错误:无法打开Optional.None.为什么我收到此错误?
单元格不是在故事板中创建的.我使用tableView.registerClass初始化单元格或注册其类(UITableViewCell.self,forCellReusEIDentifier:“CellSubtitle”)
以上是大佬教程为你收集整理的ios – Swift UITableViewCell detailTextLabel.text抛出错误’致命错误:无法解包Optional.None’全部内容,希望文章能够帮你解决ios – Swift UITableViewCell detailTextLabel.text抛出错误’致命错误:无法解包Optional.None’所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。