iOS: UITableView cells with multiple lines?

后端 未结 5 1387
既然无缘
既然无缘 2020-12-23 21:42

What\'s the best way to have UITableView cells with multiple lines ? Let\'s say 5.. or 6 ?

Instead of textLabel and la detailTextLabel ? Should I create a custom sty

5条回答
  •  心在旅途
    2020-12-23 22:11

    I found this worked for me on Xcode Version 8.0 (8A218a)

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath)    UITableViewCell {
            let cell = UITableViewCell()
           //MARK: word wrapping in cell
            cell.textLabel?.text = self.choices[(indexPath as NSIndexPath).row]
            cell.textLabel?.numberOfLines=0 // line wrap
            cell.textLabel?.lineBreakMode = NSLineBreakMode.byWordWrapping
    
            return cell
        }
    

提交回复
热议问题