0

I have a UITextView which has a UIWebView just below it. The frame of UIWebView is set depending on the UITextView. The frames are dynamic and keep changing in UItextViewDidChange method. Now, when the UIWebView is touched, the keyboard is dismissed. I don't want that to happen. The keyboard should stay. If I turn myWebView.userInteractionEnabled = FALSE, will I still be able to copy text from UIWebView.

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
amateurcoder
  • 97
  • 3
  • 12

2 Answers2

0

I don't know if you still be able to copy text, I think not. But here is how to deal with it.

In your touchesBegan method put this if statement

//Get the touch object from touches set.

if(![NSStringFromClass([[touch view] class]) isEqualToString:@"UIWebView"]){
        [theTextField resignFirstResponder];
    }

the theTextField is the object responsible for displaying the keyboard.

Hope this helps.

Cyprian
  • 9,423
  • 4
  • 39
  • 73
  • I don't want keyboard to dismiss at all. But touching the UIWebView automatically dismisses it. I don't want that. Also, I fear if I set this myWebView.userInteractionEnabled = NO. I won't be able to copy text from my UIWebView. What I am looking for is something like this if(![NSStringFromClass([[touch view] class]) isEqualToString:@"UIWebView"]){ [keyboard don't send away]; } – amateurcoder Apr 17 '11 at 22:46
0

When UIWebview is touched it will dismiss the keyboard. if you set WebView.userInteractionEnabled = FALSE keyboard won't dismiss and you won't be able to copy text from UIWebView. Hope it helps.

Himanshu A Jadav
  • 2,286
  • 22
  • 34