1

textview isn't becoming first responder when using iphone X but it works fine for iphone 7 and other devices. I have set the delegate for the textview and use textViewDidBeginEditing delegate method. Any ideas? Thank you!

descTextView.delegate = self

func textViewDidBeginEditing(_ textView: UITextView){
     textView.becomeFirstResponder()
} 
rmaddy
  • 314,917
  • 42
  • 532
  • 579
mir
  • 183
  • 1
  • 12
  • It makes no sense to call `becomeFirstResponder` inside `textViewDidBeginEditing`. `textViewDidBeginEditing` is only called when the text field has already become the first responder. – rmaddy Mar 09 '18 at 19:27
  • Where would you call becomeFirstResponder then? Even if I comment that out, it's not working. – mir Mar 12 '18 at 16:30
  • You don't need to call `becomeFirstResponder`. The text view will become first responder when the user taps on the text view. If you want some other code (say a button press) to trigger the text view then call `becomeFirstResponder` on the text view in the button handler or other relevant code. – rmaddy Mar 12 '18 at 16:40

1 Answers1

0


It will be better to call
textView.becomeFirstResponder()
in your viewWillAppear() method like this,

    func viewWillAppear() { 
       textView.becomeFirstResponder()
    } 


if you can add more info about what is the previous event? or when you want your textView to become first responder? that will be easy to understand your requirement.

Jeba Moses
  • 809
  • 8
  • 25
  • 1
    I want the textView to become first responder when a user taps on the textview box to type. It was working fine previously until I updated to ios 11. My only concern with calling textView.becomeFirstResponder in viewWillAppear would be that the keyboard would appear as soon as the screen loads. – mir Mar 12 '18 at 16:29