小编kur*_*ple的帖子

UITableViewCell没有显示detailTextLabel.text - Swift

细节(副标题)文本不会出现.但是,这些数据是可用的,因为当添加println()调用时,它会向控制台输出带有预期数据的Optional("data").在故事板中,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
}
Run Code Online (Sandbox Code Playgroud)

uitableview detailtextlabel swift

32
推荐指数
6
解决办法
4万
查看次数

标签 统计

detailtextlabel ×1

swift ×1

uitableview ×1