Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: UITableViewCell with custom style #2

Open
gerchicov-bp opened this issue Jul 24, 2019 · 1 comment
Open

Feature request: UITableViewCell with custom style #2

gerchicov-bp opened this issue Jul 24, 2019 · 1 comment

Comments

@gerchicov-bp
Copy link

For example how to create UITableViewCell with no subclassing but with visible detailTextLabel?

@iTofu
Copy link
Owner

iTofu commented Nov 17, 2020

Sorry for being late.
In fact, your requirement has nothing to do with the framework, it is an iOS development problem.
And hope this can still help you.

// DON'T register UITableViewCell in the beginning
// Otherwise the UITableViewCell with .subtitle style will be no chance to be created
// tableView.register(UITableViewCell.self)

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  let cell = tableView.dequeueReusableCell(with: UITableViewCell.self) ?? UITableViewCell(style: .subtitle, reuseIdentifier: UITableViewCell.defaultReuseIdentifier)
  cell.textLabel?.text = hellos[indexPath.row % 5]
  cell.detailTextLabel?.text = "(\(indexPath.section), \(indexPath.row))"
//    cell.render(text: "(\(indexPath.section), \(indexPath.row))    \(hellos[indexPath.row % 5])")
  return cell
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants