Iphone – Button events inside UIWebView

iphoneuiwebviewxcode

I want to have a on top of uiwebview, which will scroll out of view as I scroll webview downward. The problem is I am not able to raise/handle the button touchupinside event from the viewcontroller. My guess is webview is eating the event. How can I make the button raise events?
One solution is to have a subview containing the button and then have this and the webview inside a scrollview. However this has its own problems and more so because my webpage has expandable sections inside it.
I am currently adding the button as subview inside documentview of the uiwebview, so it scrolls out of view.

Any help in this regard will be appreciated. Thanks.

Best Answer

It's a WebView, so if you're button is actually on the webpage, just use a simple Name attribute on the anchor tag.

If it's not, and it's a UIButton event you are trying to listen to, chances are you wired something up incorrectly with your IBOutlets and IBActions. To send a message to a UIWebView to make it scroll, you can send the stringByEvaluatingJavaScriptFromString: message which will call javascript inside your page. Check out the docs for details.

Related Topic