0

I have a UIViewController , it has a field for putting the location , a field where I write some skills, and a uiWebView where I write the description. I use the uiWebView because I send the description in a html format to the backend. It suits my needs perfectly. What I'm having problems though , is that in iphone 4 screen the keyboard covers the uiWebView totally because the uiWebView is located from the vertically middle of the screen till the bottom.

So in order for me to make an offset and set the uiWebView above the keyboard I need to know when the uiWebView has been touched by the user (when the user has started typing on it). As much as I've searched on a solution I'm not being able to get a response from the uiWebView to tell me when it's being touched by the user , so I can then put it an offset.

So my question is , is there a way where uiWebView can tell me "Hey the user has started typing on me" ?

  • What have you actually tried and which part of it didn't work ? On a side note I'd suggest to listen for keyboard show&hide notifications instead of detecting touches or process changes in layout and detect when the web view needs to be moved up for whatever reason. The latter should work well with the larger screens where no actions will be needed. – A-Live Jan 20 '16 at 15:08
  • I tried webView.focused() , webView.becomefirstresponder() , I need something similar to focuslistener of android. Which tells the device when the user has touched the webview. I could listen for keyboard but in my case I don't need to change offset when the two first fields are touched , I need it only on the webView. – goldborn.dushi Jan 20 '16 at 15:17

1 Answers1

0

You don't need the notification from UIWebView, you need a notification from UIKeyBoard to tell you, when it's appearing on a screen.

See this article for more details: https://www.cocoanetics.com/2011/07/calculating-area-covered-by-keyboard/

arrteme
  • 393
  • 1
  • 3
  • 14
  • I could listen for keyboard but in my case I don't need to change offset when the two first fields are touched , I need it only on the webView. Ofc I can implement this one as well , but if there's anyway the uiwebview could tell me that it was touched that'd be my perfect solution. – goldborn.dushi Jan 20 '16 at 15:20
  • Some suggest overwriting UIWebView methods to determine whether webView is focused, like here: http://stackoverflow.com/questions/8474386/uiwebview-with-contenteditable-html-editing-first-responder-handling Not sure if it's the best solution out there – arrteme Jan 20 '16 at 15:34