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

Not working with UITextView #11

Open
lawmaestro opened this issue Oct 7, 2018 · 4 comments
Open

Not working with UITextView #11

lawmaestro opened this issue Oct 7, 2018 · 4 comments

Comments

@lawmaestro
Copy link

I've been unable to get this working with 'UITextView'. The example project uses a 'UITextField' which seems to work fine. However, when switching that out for a 'UITextView' that too stops working :(

@dlo
Copy link
Member

dlo commented Oct 7, 2018

Do you have a code sample you can share?

@lawmaestro
Copy link
Author

lawmaestro commented Oct 7, 2018 via email

@dlo
Copy link
Member

dlo commented Oct 7, 2018

@lawmaestro It doesn't look like it came through.

@lawmaestro
Copy link
Author

Apologies, try this:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
   let cell = tableView.dequeueReusableCell(withIdentifier: CellIdentifier)! as UITableViewCell
   let textField = UITextField()    // Works with this...
// let textField = UITextView()    // but not with this
   textField.translatesAutoresizingMaskIntoConstraints = false
   cell.addSubview(textField)
   textField.text = "Hello"
   textField.heightAnchor.constraint(equalToConstant: 30).isActive = true
   textField.topAnchor.constraint(equalTo: cell.topAnchor, constant: 15).isActive = true
   textField.leftAnchor.constraint(equalTo: cell.leftAnchor, constant: 15).isActive = true
   textField.rightAnchor.constraint(equalTo: cell.rightAnchor, constant: 15).isActive = true
   textField.bottomAnchor.constraint(equalTo: cell.bottomAnchor, constant: -15).isActive = true
  return cell
}

If you switch out the cellForRowAt in the example project for this ^

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

No branches or pull requests

2 participants