hannes
hannes

Reputation: 537

Dismiss Keyboard in UITextField

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

Upvotes: 1

Views: 109

Answers (3)

iPeter
iPeter

Reputation: 1360

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

Upvotes: 3

JigneshP
JigneshP

Reputation: 344

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".

Upvotes: 4

iAnurag
iAnurag

Reputation: 9346

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

Upvotes: 2

Related Questions