Is there a way to enable touch-hold image save in UIWebview - iphone

Ok so in mobile safari you can pull up a web page and touch and hold on an image to save it to the iPhone's photo library. In a UIWebview on a view this does not happen (it pops up the alt-text and never prompts you). I'm wondering if anyone knows a way to turn this feature on.

One way to do it (on tap) would be to
grab the content
Do smart img tag finding to find all img tags
find / replace with a link to some arbitrary place http://foo.com?REAL_IMG_SRC
overload - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType in your delegate
intercept all links that contain foo.com
Use the REAL_IMG_SRC to download/present save options/etc...

Related

How to go back from Safari to UIWebView (iphone)

I really want to thank you all you guys first , I began iOS programming learning several weeks ago ,and I have learnt a lot from here these days,.
I have a UIWebView and loading some html content with "loadHTMLString" method, when i click hyperlinks in the UIwebView, It comforms the
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType{
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
[[UIApplication sharedApplication] openURL:[Request URL]];
return NO;
}
return YES;
}
to open a Safari.
My question is: Can I go back from the Safari to the UIWebView? how?
You can't get Safari to send the user back whenever you want, but one way to get back to your application is by creating a custom URL scheme (e.g. myapp://return, or whatever scheme makes sense to you), assuming that the web page the person is going to can have links that are intended to go back to your appliaction.
You can do this by registering that your application handles the URL scheme, and then processing the request appropriately when iOS tells you to. The Apple docs are fairly complete about this.
But if you want your application to be able to arbitrarily pull people back whenever you want, I don't think that's possible. Safari isn't under the control of anyone but Apple.

Do anyone know how to make a dropdowntree menu in ipad?

I really need to know how to make the dropdownTree Menu in ipad. I need to create it in my ipad app. If anyone out there knows it, please share it with me. Thanks a lot in advance.
Apple doesn't provide a native component for GUI trees. Writing one on your own can take a long time. I would rather use a webview and use a javascript tree component such as jstree or Tree Menu.
You can easily interact with the webview using these methods:
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
// UIWebViewDelegate method, to communicate from within the webview with the native objective-c code
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

Download to iphone via iphone app

In my iPhone application i want to allow a user to download a file.(video file)
From a UIWebview i have linked download button to the video file.
Didnt worked !
Any ideas ?
Please help !
AFAIK there is not way of downloading a file from WebKit component the same way it's done on the Desktop. If you want to do something like this you should interface with webView by using something like:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
so that you can download the file properly.

Best approach for simple link within UITextView

I am creating a dictionary lookup application. The user selects a word from a UITableView and the app displays the definition. In some cases the word will be similar to another word, so I want to display "See Also:" followed by a list of similar words that when touched, bring up another definition.
In searching here on links within UITextViews, most of the answers involve linking out to the web, which is not really what I need. I simply want to get control when the user touches a word so that I can change the view.
Is UIWebView the only way to do this, or did I miss something obvious in the SDK? Also, I'd prefer to stay within the native SDK and not go the three20 route.
Thanks!
I would use another UITableView to make this work. Your list of similar words will probably be in NSArray format already, so it would be pretty easy to set up another UITableView instead of a UITextView to display the list, and given that you already have this code working for the main UITableView, you already know how to make them clickable!
A UIWebView will be the only thing that suits here I'm afraid. Data detectors are the only way to link inside of a UITextView, and they will only respond to the appropriate data types (Phone number, web page, address)...
Links can be done the normal way:
<a href='http://someotherword'>someotherword</a>
Setup the webviewdelegate to snag any link requests (and prevent them from being opened in the browser) so that you can open them in your own handler:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
{
if(navigationType == UIWebViewNavigationTypeOther) return YES; // Allow direct loading
NSString *myWord = [[request URL] host];
// do something with myWord... say open another word
return NO; // Don't let the browser actually perform this navigation
}

Using iphone UIWebKit to create a web browser, problems with getting url

So I am creating a web browser for iPhone for my class and I am having an issue where whenever I submit a form-like thing from a website, it doesn't update my address bar text (which is a UITextfield). As an example, if I go to google.com on my browser and so a search for something in the search field and hit submit, it loads a new page without changing my address bar (it's still on google.com). I have it to change for links, but I don't see how to make it so it works for forms like this. I added a NSLog in my webViewDidFinishLoading function and it doesn't say the page is loading, so I'm not sure how to detect when it changes this way. Does anyone have any ideas why it's not working?
Intercept it in this method instead:
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType;
The navigationType can be UIWebViewNavigationTypeLinkClicked , UIWebViewNavigationTypeFormSubmitted or others. And [request URL] will be an NSURL object with the page URL about to be loaded.