-2

Let's say I have a web app which is designed for the desktop, and I want to create simple and straightforward access for iOS. Consider it a simple form with a submit button.

Some options that would be great are:

  1. Redesigning the web interface for mobile
  2. Creating a REST-style API for access

Unfortunately neither of these options exist, so I have to create a wrapper in iOS. I have no problems creating the basic interface, authentication, etc...but now I need to be able to simulate selection of a radio button, maybe filling in a few fields, and clicking submit.

I'd like to capture those details in a native iOS interface (already done), and submit over the wire...the only practical theory I've heard of is to collect that info, pass it to a hidden UIWebView, and execute some JavaScript from the UIWebView...but I don't see any examples here, plus I want to make certain I'm on the right path.

Any ideas?

3
  • you are getting down voted because A) you should make a native app or B) implement a mobile friendly web front end. I'm not sure what the ruling is for UIWebView wrapper apps going into the app store but thats going to be a bad UX imo. Commented Aug 24, 2015 at 19:07
  • You question is a little bit confusing. But you should look at WKWebviews which are/will be the replacement for UIWebViews and WebViews. Data can pass back and forth between app and WKWebviews as well as sending Javascript calls via callback to the WKWebviews a WKWebviews can do the same to the app, therefore controlling the app and any other WKWebviews in it. Have look at this to see what I mean. forums.tumult.com/t/… Commented Aug 24, 2015 at 22:11
  • Solved it myself, using a hidden UIWebView which calls Javascript to manipulate the page elements. Commented Aug 25, 2015 at 21:31

1 Answer 1

3

Implement the UIWebView's delegate method webViewDidFinishLoad: in your UIViewController and in there you call [graphView stringByEvaluatingJavaScriptFromString:@"methodName()"]; to make sure the function gets called after the page has been loaded.

Calling Javascript using UIWebView

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks - figured it out this morning, but pretty much what I did!
Nice work, please mark my answer as correct if it helped.
Done; I wish the docs were more clear on this, but that's always the case!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.