How can my CocoaTouch app react to the user pressing an HTML input button inside a UIWebView?
I’ve got an UIWebView inside an Cocoa Touch application.
I would like to have an <input type='submit'开发者_开发知识库>
or <input type='button'>
, and if the user presses this button, then I would like to react inside the application.
Is there a delegate/callback/javascript solution to do this?
Best regards
ch.h
First, in your web view, you need to trigger the loading of a URL that uses a custom URL scheme (e.g. appAction://).
Then implement webView:shouldStartLoadWithRequest:navigationType:
in your UIWebView's delegate, and in that method, catch the loading of that URL scheme. Use the rest of the URL as you see fit to determine what action to take.
You can find much more detail on how to do this in this stackoverflow question.
精彩评论