KeyboardAdjuster
KeyboardAdjuster copied to clipboard
Not working with UITextView
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 :(
Do you have a code sample you can share?
Hey,
I’ve attached a hacked version of the example project showing it working for a textfield but not a textview.
Cheers, Adam
On 7 Oct 2018, at 15:32, Dan Loewenherz [email protected] wrote:
Do you have a code sample you can share?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lionheart/KeyboardAdjuster/issues/11#issuecomment-427657897, or mute the thread https://github.com/notifications/unsubscribe-auth/AX1WCth3TNz80-MVXdfFJyXFi_3Ys5Ppks5uihBqgaJpZM4XLygg.
@lawmaestro It doesn't look like it came through.
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 ^