I want to show a popover view on top of a webview. And the popover should be shown on selecting any UI element in webview. I am able to capture the touch event in a Javascript code . Can anyone help me.. Is it possible to post a notification event from the Javascript..? Is there any other way of achieving this..?
Thanks.
This is exactly what PhoneGap does. The idea behind it is that in response to the touch, your JavaScript loads a particular URL, possibly with a custom scheme. The web view delegate's -webView:shouldStartLoadWithRequest:navigationType: method is called before the web view actually makes the request. If the implementation of that method recognizes the URL, it can then take whatever action it likes, such as displaying a popover view.
You can easily call your scripts (with in the sandbox) from your objective-c methods. Thw Web kit has the methods for evaluating Script codes [webview stringByEvaluatingJavaScriptFromString:#"myJavascriptFunction()"];Check this tutorials to learn dig deeper Tutorial-1 and Tutorial-2.. hope this helps you...
Related
How do you use an ajax script on an iPhone app?
I have a jquery script on my webpage that i would like to be on the view controller for my new app.
<jquery...code...>
Lets pretend the above is the jqueury code. How would i port this over to the iPhone view controller? Thanks sorry the question is so simple.
(all the code does is display a loading box that spins around and around and its quite pretty. Im probably going to put an image inside it )
Unless you're using a UIWebView in which case you simply embed a web page (including the JS code) into your app, jQuery (or rather Javascript and the DOM) is completely distinct from Objective-C and Cocoa Touch, so you can't use it, and the only option is to rewrite the same code in the new language and framework.
http://imgur.com/3ZBCsDn
Can't post the image on the site but there it is.
I have been trying to find if this is a template or a separate nib file ala the page turn animation. Any help would be greatly appreciated.
That is called a UIActionSheet. It is created entirely in code, so it's limited to some pretty simple stuff (i.e. a few buttons, one of which is the cancel button, and one of which can be marked "destructive"). Just consult the documentation for the UIActionSheet class; it tells you all there is to know about it.
Also, here's the discussion in my book:
http://www.apeth.com/iOSBook/ch26.html#_action_sheet
Using Woodwing, we have a page that has custom html in it, using the custom web widget.
That widget has an anchor tag, that when tapped, opens a page in safari.
However, if we create the same page using the HTML widget, and a link overlay, that triggers a ModalView to display.
I'm assuming this has something to do with WoodWing's (un)documented protocols for the anchor tags, that are captured by the WoodWing shell application and used to trigger the "ModalView" display. Since everything in Woodwing generates an XML that is parsed when the app is loaded, and I've done numerous applications, this seems reasonable. However, there is very little technical documentation.
My question is: does anyone know any documentation on those protocols, or a way I can use custom-html to trigger the ModalView? I've tried replacing "http" with "ww" but no dice. It's possible it's javascript but I'm suspecting protocols...
The UIWebViewDelegate defines the webView:shouldStartLoadWithRequest:navigationType: method that your view controller can implement. In this implementation, your code shoudl decide if it wants to handle the request (user click) or let the UIWebView handle it normally.
For displaying a modal as a result of a click, this method would display the modal and return NO.
The default HTML widget implementation doesn't support this out of the box. There are two ways that you can do to achieve this;
Implement what they call a 'custom object'. They documented this feature, if you have access to their documentation this should be relatively easy to figure out. It allows you to write native objects and inject them into both the .ofip format and the application.
Implement a modal dialog within the widget (in HTML). This is less convenient but possible to do (if you have a fullscreen widget).
Create the specific URL for open as you mention in your comment(ww://string.string).
Then in UIWebView Delegate method (webView: shouldStartLoadWithRequest: navigationType:) get the redirect URL. If redirect URL is equal to you mention before then perform your action.
Let me know if this answer help you.
Thanks,
I have an HTML file that's loaded from a UIWebView. I'm looking to do the opposite - link from the HTML file to a different view controller. How would one go about doing this?
the html file is a local file within the app.
thanks for any help.
You can do this by adopting UIWebViewDelegate protocol and implement the webView:shouldStartLoadWithRequest:navigationType: method. Here you can capture all requests and selectively use them for your purpose.
Define links such as yourapp://yourviewcontroller/argument within the HTML page and parse them in the above mentioned delegate method and load the appropriate view controller.
try using three20 library
https://github.com/facebook/three20
there is a helpful class for this named TTStyledText which render html as well as custom links. just need to map the links with ur controller. Go through the samples in three20!
Sorry for the short answer, but there are a lot of parts to this. Check out this link.
http://forums.macrumors.com/showthread.php?t=463491
It looks like you might have to register the url with Apple. I know that for the maps application its able to do urls like map://... and I've seen other apps do it too, I just don't know the exact process.
Update: looks like this exampe from Apple should help.
Hey guys, I've recently implemented a UITextView into my app, and activated UIDataDetectorTypeAll. Everything works perfect, except when users click on the link, phone number, etc. it automatically kicks them out of my app and into the website, etc. Is there any way to have the website appear in my own app in a custom view, or at least have a popup that asks the user if they want to be taken to the website, call, etc?
Thank you!
Use a UIWebView and message it to load the URL. Wait, that's no help, sounds like you need to intercept the link so you can know the URL. The UITextView may be calling UIApplication's openURL function. This is ugly, but what if you replaced that openURL with your own using categories or subclassed UIApplication and added your own openURL function to override the one at the UIApplication level. Once there, you have a chance to intercept the call and direct it to your own UIWebView or at least pop up a UIAlertView.