So I know this type of thing is easily achieved in Java using JSP files, but I am wondering how I can mix code and html inside an iOS view. The reason I need to do that is that I have (local) html content being loaded into a UIWebView, and if they click on an html button, I need it to fire like an IBAction for example, and do some stuff locally.
Is this possible in XCode? What am I missing?
You can not have Objective-C code mixed with an HTML file that runs locally on a
UIWebView. That said, there are some workarounds that may fit your needs.One that I’ve used, is to have the HTML link to a custom URL, and detect that on the appropriate method in the
UIWebViewdelegate class, as follows:In that method, you would check for the
URLschema you created by means of checking therequestparameter, and then decide what selector to code on your Objective-C code.