栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

UITableViewCell不显示detailTextLabel.text-Swift

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

UITableViewCell不显示detailTextLabel.text-Swift

这里有同样的问题(从我读到的内容来看,也许是iOS 8中的错误?),这就是我们的解决方法:

  1. 从情节提要中删除原型单元

  2. 删除此行:

var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath:indexPath) as UITableViewCell

  1. 替换为以下代码行:

    let cellIdentifier =“单元格”

    var cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)as?UITableViewCell
    如果单元格== nil {
    单元格= UITableViewCell(样式:UITableViewCellStyle.Value2,复用标识符:cellIdentifier)
    }

Swift 3.1更新

let cellIdentifier = "Cell"var cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)if cell == nil {    cell = UITableViewCell(style: UITableViewCellStyle.value2, reuseIdentifier: cellIdentifier)}

Swift 4.2更新-简化

let cell = UITableViewCell(style: UITableViewCell.CellStyle.value2, reuseIdentifier: "cellId")


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/448349.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号