1
votes

Anyone has a Solution for my Problem? I have an UITextField and want to Dismiss the Keyboard after pressing on Return. I added the UITextFieldDelegate and want to set the Delegate on my TextField, but the error remains...

Here is a Screenshot of my Problem

3
Your chatTextField is of what type? UITextField or UITextView? - iPeter
Are you sure that, your chatTextField is kind of UITextField? - Viral Savaj

3 Answers

4
votes

Which one you want to use. TextField or TextView ?

because you create the "IBOutlet" of "TextView" but set the delegate to "TextField".

if you want to use "TextField" then remove "TextView" from storyboard and use "TextField" instead of it and create it's "IBOutlet".

and if you want to use "TextView" then use the "UITextViewDelegate" instead of "UITextFieldDelagate".

3
votes

Extend UITextViewDelegate instead of UITextFieldDelegate as your variable chatTextField is of type UITextView.

2
votes

Your chatTextField is UITextView and you are setting it UITextField's delegate. ADD UITextViewDelegate after class declaration.