0
votes

while I develop iOS application with swift, I wondered why apple did not support auto-dismiss keyboard function in application. This means if I implement a TextLabel on screen, I tapped that label, Keyboard appears, but did not dismissed automatically.

I thought many of application keyboards need to dismissed when users tap on outside of the keyboard screen or click 'done' button on a screen. However, basically, I have to implement keyboard dismiss function on every ViewController. And I think this is code duplication.

Anyone can explain me about apple's application method implementation philosophy and how can I wrote an reusable function, which is not duplicated function in every ViewController scheme.

1
Every app is different. Not every app wants auto dismiss. If you want it, implement it.rmaddy
@rmaddy means that is auto dismiss function option for every app developer choices?sogo
Then why TextView supports keyboard edit function in default likewise? I mean, is 'text' means editable unlike 'label'?sogo
A UITextView/UITextField is editable. A UILabel is not.keji
I think that it is necessary for every app, BUT the timing varies on when it should be dismissed. Ex: For a texting app after I click the send button I would like to send another text. Then I shouldn't dismiss the keyboard.keji

1 Answers

0
votes

Transposed from Comments:

In general apps where the main function utilizes the keyboard would rather control when the keyboard dismisses themselves instead on relying on an auto feature.

Ex: For a texting app after I click the send button I would like to send another text. Then I shouldn't dismiss the keyboard.

If you are dismissing the keyboard multiple times than I would try making a view controller class that handles that and subclass it. You can observe when the keyboard is shown and add a button on top of your view so when it is clicked the keyboard dismisses using [self.view endEditing:YES];