UITextView not displaying keyboard when using its delegate to detect when textview is begun to be edited

StackOverflow https://stackoverflow.com/questions/19119355

  •  30-06-2022
  •  | 
  •  

Question

I'm trying to work with a textview but its having odd reactions. The textview is where the user enters their information that will be sent to me. Basically I've designed my interface in interface builder and got it looking correct. I have entered place holder text: "Enter your issue here". When I run the app the textview works correctly, I can delete the pre entered text and compose a message. However I need to place a ui tool bar above the key board so I can give the user a way of canceling input. i've implemented its delegate, UITextViewDelegate and implemented

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{}

which does get fired when I tap the text view. However the textview now does not give me the keyboard! it just sits there awaiting input but never displays the keyboard. I need to use textViewShouldBeginEditing so I can tell when the user touches the text view to activate the text entry and attach the uitoolbar I. If I remove the textViewShouldBeginEditing the text view goes back to responding being tapped. I've tried a good few thing, ensured the right connections are made in interface builder, set the delegates etc, etc but nothing seams to fix this.

Any suggestions are welcome and if any more information is needed let me know.

Many thanks in advance.

Was it helpful?

Solution

Are you returning TRUE in the delegate?

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
       //Do your things
       return TRUE;
}

OTHER TIPS

you can try this

[[NSNotificationCenter defaultCenter]
 addObserver:self
 selector:@selector(myMethod)
 name:UITextFieldTextDidChangeNotification
 object:myTextField];

you can use UITextFieldTextDidBeginEditingNotification or UITextFieldTextDidEndEditingNotification

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top