Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - UITextView dismiss keyboard in storyboard

I have a UITextView in which users could type some notes and save them. I want to dismiss the keyboard when the user drags on the edge of the keyboard and pull it down (just like in Message). I see that in storyboard -> attributes inspector -> Scroll View -> Keyboard, there is a drop down menu where I can choose the way of dismissing the keyboard. I've tried both Dismiss on drag and Dismiss interactively but nothing happens. I've tried setting the view controller that manages the text view to be the delegate, but there does not seem to be a method through which I can interact with the keyboard. Any idea?

like image 452
ljiatu Avatar asked Mar 30 '14 01:03

ljiatu


People also ask

How to dismiss the keyboard in swift?

Via Tap Gesture This is the quickest way to implement keyboard dismissal. Just set a Tap gesture on the main View and hook that gesture with a function which calls view. endEditing . Causes the view (or one of its embedded text fields) to resign the first responder status.

Which delegate function removes keyboard in UITextField?

If you have a UITextField and you want to hide the keyboard when the user is pressing the return key, use the textFieldShouldReturn function. Be sure you have set the textField. delegate = self in your viewDidLoad() function.

How do you dismiss a keyboard?

Android devices have a solution; press the physical back button (provided on some mobile phones) or the soft key back button, and it closes the keyboard.


1 Answers

I had a similar issue. I had a UITextView located in one of the cells of a UITableView. Setting a Keyboard attribute of the TextView to "Dismiss on drag" didn't work. The solution was to set the TableView's attribute Keyboard to "Dismiss on drag".

I think that your ScrollView might be contained in some other control, e.g. TableView. Then it is the container that performs the scrolling. If that is the case you should set the container's Keyboard attribute to "Dismiss on drag".

If that doesn't work then my other suggestion is that you don't have enough content in your ScrollView to actually do the scrolling. I would make sure that you have the length of your ScrollView's content large enough so it doesn't fit the screen.

Let me know if any of these worked.

like image 179
oranJess Avatar answered Sep 27 '22 20:09

oranJess