-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?

kalikkalik
  • 187
  • 8
  • 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. – anders Aug 24 '15 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. http://forums.tumult.com/t/get-control-of-feedback-from-webpage-or-ios-mac-app-using-the-newish-wkwebview/3503/6?u=markhunte – markhunte Aug 24 '15 at 22:11
  • Solved it myself, using a hidden UIWebView which calls Javascript to manipulate the page elements. – kalikkalik Aug 25 '15 at 21:31

1 Answers1

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

Community
  • 1
  • 1
anders
  • 4,168
  • 2
  • 23
  • 31