gpt4 book ai didi

UITableViewCell 不显示 detailTextLabel.text - Swift

转载 作者:IT王子 更新时间:2023-10-29 05:04:36 25 4
gpt4 key购买 nike

详细信息(副标题)文本不会出现。但是,数据是可用的,因为当添加 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com