7 Replies Latest reply: Feb 14, 2009 5:59 PM by Kuso Lito
Aatif Level 1 Level 1 (35 points)
While in Safari, tapping on an image pops up a menu showing options like 'set as wallpaper' etc ... but when viewing same webpage in UIWebView, tapping on image shows nothing.
Can anybody tell what is it?

Mac Mini, Mac OS X (10.5.4)
  • 1. Re: Images in UIWebView
    GW1921 Level 1 Level 1 (40 points)
    What makes you think Safari is a thin wrapper around UIWebView?
  • 2. Re: Images in UIWebView
    RickMaddy Level 4 Level 4 (1,320 points)
    One idea I can think of is to make all the images links. Then your webview delegate can trap all the image taps and you could then present your own menu of actions.
  • 3. Re: Images in UIWebView
    Aatif Level 1 Level 1 (35 points)
    GW1921,
    Thats what I want to know, the relation between UIWebView and Safari. If I try to open some webpage from a webview, the info sent to the remote host is not same as that sent by mobile Safari. e-g some webpages show error that "This page can be viewed only through mobile safari" when I try to open them through a UIWebView.

    RickMaddy,
    Since I just want to show ANY website/webpage like hotmail, google etc ... I have no right to set images as links ...
  • 4. Re: Images in UIWebView
    RickMaddy Level 4 Level 4 (1,320 points)
    UIWebView is not Safari, not even close. UIWebView renders HTML including CSS and images. It handles links. It processes Javascript. But it's not a full blown browser.

    Try going to a site like http://www.useragentstring.com to see what you get for a user agent string compared to Safari.

    My suggestion about image links was given with the assumption you wanted to display your own, app specific, content. Never mind.
  • 5. Re: Images in UIWebView
    Aatif Level 1 Level 1 (35 points)
    Hm, then how can I set some specific user agent string in order to view those sites which are specifically built for mobile safari? Or is there any way to use mobile safari in my app instead of webview?

    Thanx for the user-agent site.
  • 6. Re: Images in UIWebView
    RickMaddy Level 4 Level 4 (1,320 points)
    I just ran a test and found a way to do this. The UIWebView delegate method 'shouldStartLoadWithRequest' has as one of its arguments an NSURLRequest object. Happily this is really a NSMutableURLRequest (at least in my quick test). A mutable request allows you to set any HTTP header including user agent. No guarantee that a given site will work properly inside UIWebView but at least you can try different user agent strings and see what happens.

    You can't use mobile Safari IN your app but you can launch it FROM your app. Of course your app terminates at that point.
  • 7. Re: Images in UIWebView
    Kuso Lito Level 1 Level 1 (0 points)
    Hi, I tried setting the user-agent string with NSMutableURLRequest, but didn't work. Have you been able got this to work?