ios - 详细文本标签不显示

标签 ios swift

我有一个函数,我想要一个大文本标签和两个较小的文本标签。 该函数从数据库中获取数据,并将它们重复放入我的 3 个文本标签中。 但是,只有我的默认文本标签可见,两个详细文本标签都不显示。

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    // Retrieve cell
    let cellIdentifier: String = "BasicCell"
    let myCell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)!
    // Get the location to be shown
    let item: Parsexml = feedItems[indexPath.row] as! Parsexml
    // Get references to labels of cell
    print(item)
    myCell.textLabel!.text = item.name! + " | " + item.address! + " " + item.nr!
    myCell.detailTextLabel?.text = "City: " + item.city!
    myCell.detailTextLabel?.text = "category: " + item.category!
    //Label styling
    myCell.textLabel?.textColor = UIColor(white: 1, alpha: 1)
    myCell.textLabel?.font = UIFont(name: "HelveticaNeue-Bold", size: 12)
    return myCell
}

如何让我的详细文本标签在 swift 3 中显示?

最佳答案

这意味着您有一个包含 3 个 UILable 的自定义单元格? 如果是这样的话,这一行应该是这样的

 let myCell: YouCustomCell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)!

然后你就可以使用

myCell.1stLable.text = item.name! + " | " + item.address! + " " + item.nr!
myCell.2ndLable.text = "City: " + item.city!
myCell.3rdLable.text = "category: " + item.category!

您必须在 Storyboard中设置单元格标识符。

关于ios - 详细文本标签不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40202453/

相关文章:

ios - JSQMessagesViewController,RegularTaillessImage 不适用于图像

ios - Swift 3 转换

ios - ios-charts条形图图例中有多个系列(标签)

ios - 数字键盘保持打开状态但禁用所有按钮?

ios - 在UITableView和UINavigationBar之间删除

ios - 更新时跟踪 NSManagedObject 属性并立即更新 View

ios - 字典无法识别键类型

ios - Sprite 套件接触检测

ios - 状态栏和导航栏的颜色不同,但实际上它们应该是相同的

objective-c - MKMapKit 和谷歌磁贴位置