UITableViewCell 不显示 detailTextLabel.text - Swift

标签 uitableview swift detailtextlabel

详细信息(副标题)文本不会出现。但是,数据是可用的,因为当添加 println() 调用时,它会将 Optional("data") 与预期数据一起打印到控制台。在 Storyboard中,UITableViewController 设置为适当的类,Table View Cell Style 设置为“Subtitle”,重用标识符设置为“cell”。如何获取显示的字幕信息?

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

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

    dispatch_async(dispatch_get_main_queue(), { () -> Void in

        cell.textLabel.text = self.myArray[indexPath.row]["title"] as? String
        cell.detailTextLabel?.text = self.myArray[indexPath.row]["subtitle"] as? String

        println(self.myArray[indexPath.row]["subtitle"] as? String)
        // The expected data appear in the console, but not in the iOS simulator's table view cell.

    })
    return cell
}

最佳答案

您的代码看起来不错。只需转到 Storyboard 并选择表格 View 的单元格 -> 现在转到属性检查器并选择副标题的样式。

根据下面的屏幕截图进行操作。

Change this option

希望对您有所帮助..

关于UITableViewCell 不显示 detailTextLabel.text - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27221003/

相关文章:

uitableview - 以编程方式设置静态单元格的 detailtextlabel

uitableview - 当选择时如何在 UITableView 中显示隐藏的字幕?

iphone - NSFetchedResultsChangeDelete 未被触发

ios - 嵌入在 UITableViewCell 中的 UICollectionView 内的 UICollectionViewCell 被重复

ios - 减慢 UITableView 中的行插入动画

ios - uitextview 在键盘顶部快速添加像笔记应用程序一样的 uitoolbar

ios - 使用所需的便利初始化进行解码时如何修复 "Extra argument in call"?(编码器 :)?

ios - 如何将 JSON 解析为 [String : AnyObject] in Swift

ios - DetailTextLabel 不显示在 iOS 8 xcode 6

iphone - 我的 UITableView cellForRowAt Index for Single Selection 有什么问题?