Images in UIWebView

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?

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.

Similar Messages

  • Help load photolibrary image in to iphone UIWebView?

    Is it possible to load an image from iphone photolibrary to a UIWebView window? Something is wrong here:
    - (void)useImage:(UIImage *)theImage {
    imageView.image = theImage;
    I think it doesn't understand ".image". Which is what I use in UIImageView. What did I miss?
    Any idea?

    BTW
    The Error below the above code is:
    "error: request for member 'image' in something not a structure or union"

  • Loading pdf file from iPhone Documents folder into a UIWebView

    I'm currently trying to include the ability for my App to download a "pdf" file from the web,... display the image in a UIWebView,.. save it to the iPhone,... and later redisplay it in the same UIWebView while "off line". I've been able to do everything but get the web view to load/display the stored pdf file. The App finds the .pdf file...
    Here's the path it finds in the Simulator...
    Image File Path: /Users/FCR/Library/Application Support/iPhone Simulator/User/Applications/8E29ACDF-4A56-4AC2-BFA0-C4F8E00E1481/Documents/AD_K EWR.pdf
    ... but I'm not much into html and can't seem to come up with a url scheme to load the image. I've tried several attempts using the URL... "file:///" ... but so far haven't been able to get the file (which is in the iPhone's Documents folder) to display. I seem to be about one line short of a workable solution.
    Can anyone offer a bit of code (help) to accomplish this seemingly easy task of displaying it in the UIWebView?... It would be much appreciated!

    EdOfTheMountain wrote:
    Thanks for your post and sharing your solution.
    Can you please post the code snippet used to download and save the PDF to the iPhone? I did not know you could do that.
    -Ed
    Ed,... Here's the code ... I've cut and pasted from a couple different routines, but you should get the point...
    Ric
    - (BOOL)downloadPDF:(NSString *)pdfFileName
    // Download a (pdf) file
    BOOL success = NO;
    NSString *urlStr = \[NSString stringWithFormat:@"http://... web path to file .../%@", pdfFileName\];
    if(urlStr)
    NSURL *PDF_URL = \[NSURL URLWithString:urlStr\];
    NSMutableData *receivedData = \[NSData dataWithContentsOfURL: PDF_URL\];
    if(receivedData)
    success = YES;
    NSLog(@"PDF downloaded... Save it to file: %@",pdfFileName);
    NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
    if (paths.count > 0)
    NSString *documentsDirectory = \[paths objectAtIndex:0\];
    NSString *filePath = \[documentsDirectory stringByAppendingPathComponent: pdfFileName\];
    if(\[receivedData writeToFile:filePath atomically:YES\])
    success = YES;
    NSLog(@"Saved file: %@",filePath);
    else
    NSLog(@"Failed to save PDF to: %@",filePath);
    return success;
    }

  • How to open DOC/XLS files using UIWebView on iPhone 3.0?

    Hi,
    I am using the following code to display doc/xlst files on UIWebView. It's surprised that I can get the content of the file but cannot show in WebView.
    NSData *myData = [NSData dataWithContentsOfFile: fileDesPath];
    NSString *ext = [m_openFiles.fileExtension lowercaseString];
    NSString *mimeType;
    if ([ext isEqualToString:@"doc"]) {
    mimeType = @"application/msword";
    }else if([ext isEqualToString:@"xls"]){
    mimeType = @"application/vnd.ms-excel";
    }else if([ext isEqualToString:@"wma"]){
    mimeType = @"audio/x-ms-wma";
    }else if([ext isEqualToString:@"jpg"] || [ext isEqualToString:@"jpeg"]){
    mimeType = @"image/jpeg";
    }else if([ext isEqualToString:@"tif"]||[ext isEqualToString:@"tiff"]){
    mimeType = @"image/tiff";
    }else if([ext isEqualToString:@"htm"]||[ext isEqualToString:@"html"]){
    mimeType = @"text/html";
    }else if([ext isEqualToString:@"mov"]){
    mimeType = @"video/quicktime";
    }else if([ext isEqualToString:@"mp4"]){
    mimeType = @"video/mp4";
    }else if([ext isEqualToString:@"txt"]){
    mimeType = @"text/plain";
    }else{
    mimeType = [NSString stringWithFormat:@"application/%@", ext]; //pdf
    NSLog(mimeType);
    //Here, I can get the myData. The value is the content of the doc file.
    if (myData) {
    [self.myWebView loadData:myData MIMEType:mimeType textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:fileDesPath]];
    After loadData, it cannot show anything in webview!
    Can someone help me in this matter?
    Thanks,
    Message was edited by: Small Apple

    Hi Maurício -
    For your future reference and for the information of everyone who comes across this post in the future:
    We host all of our DataPlugins on our website at ni.com/dataplugins.  There are hundreds of file formats supported through the available DataPlugins, and there is also a link on that site where you can request a DataPlugin be written for file formats that aren't currently supported (such as custom *.CSV files).
    Derrick S.
    Product Manager
    NI DIAdem
    National Instruments

  • View Doc (pdf, image, .doc) imported as BLOB files in UIImageView within a UIScrollView.

    Hi,
    I am new to IOS programming and after researching on topic i found post saying it is possible to view BLOB file in uiimageView.
    I have already done sucessfully for BLOB file of Image. but i can not view pdf file, even if i got NSData.
    /****** from SP ****/
    Insert TestBlob(tbName, tbDesc, tbBin) Select
    'Test.pdf','PDF file', BulkColumn from Openrowset( Bulk
    'C:\blob\udoc\81.pdf', Single_Blob) as tb
    /****** from my App *******/
    NSString *strImage; // String has BLOB file from DB
    NSData *imageData = [self dataFromBase64EncodedString:strImage];
    UIImage *image = [UIImage imageWithData:imageData];
    UIImageView *m_oImageViewer = [[UIImageView alloc]init];
    m_oImageViewer.image = image;
    m_oImageViewer.frame=CGRectMake((self.view.frame.size.width/2)- 250,60,500,500);
    [self.view addSubview:m_oImageViewer];
    -(NSData *)dataFromBase64EncodedString:(NSString *)string{
    if (string.length > 0)
         NSString *data64URLString = [NSString stringWithFormat:@"data:;base64,%@", string];
        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:data64URLString]];
        return data;
    return nil;
    Please help me. i have already viewd Image but PDF comming empty. i do not want to edit or do anything only user should be able to view uploaded Doc from IPD App. and Doc can be image, pdf or .doc or excel sheet. i get BLOB file for all file types which i pass to my App.
    IS what i am doing is correct? as i imagine BLOB is common for all file Types. still i can not see pdf file(i have not tried other file formate only .png and pdf).
    Please guid me if i am missing anything.

    Hi Sreelatha. The best example code for your purpose is the Scrolling sample app I referred to previously. The word Scrolling in that post is a link to the download page. I think that code will answer all your questions about how to init a UIImage, then use it to init a UIImageView, and then position the UIImageView frame in a UIScrollView. Two cases are demostrated: 1) Scrolling horizontally through a series of images; 2) Scrolling both H & V over a single image which is several times larger than the window.
    You might also be interested in the PageControl sample app in case you want to add a page control to your scroll view.
    Reading your last post again... I sure hope we've been discussing images (like jpegs?) in this thread. This isn't about reading and rendering the actual xls, pdf and doc files, is it?? Of course the iPhone handles html beautifully, so for example, an html representation of a doc file would play nicely. But in that case you'd want a UIWebView, not a UIImageView.

  • Loading local sound into UIWebView?

    I'm able to successfully load a local html-file into a UIWebView, and from that load a local image via the html-code.
    Loading a local sound-file from the UIWebView, however, is a different matter.
    Does anybody know why the code below only manages to display a local image but no local sound, and what the solution would be?
    (you can find the code here sinc this forum does not enable showing code unformatted in any way that I know of):
    http://forums.macrumors.com/showthread.php?p=6730846&posted=1#post6730846

    mTheBackgroundPath = [[NSBundle mainBundle] pathForResource:@"black_background" ofType:@"jpg"];
    mTheBackgroundPath = [ mTheBackgroundPath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
    mTheBackgroundPath = [ mTheBackgroundPath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    mTheBackgroundPath = [@"file://" stringByAppendingString:mTheBackgroundPath];
    Then I just used that path in the background="" tag in the body of the html.

  • Enabling horizontal scroll in UIWebview

    Hi all,
    Is there any way to load a pdf document in a UIWebview so that it can
    scroll horizontally instead vertically?
    Is it possible?..
    If so pls some one gimme me the way to do this..
    I wanna pick the words in pdf as we can do in a webview and also I wanna
    enable search for the word as we can do in a webview. So having an image and
    loading it in a webview wont suit my requirements, I hope so. So I did load
    pdf in a webview. Now my requirment is to load the same such that it could
    scroll in a horizontal pattern.
    Can anyone help me??????

    With the current version of VC there is no horizontal scroll bar in the Flex tables possible.

  • PDF zoom in UIWebView

    What a nightmare, I've got over 2 years of cocoa experience but the iPhone SDK is a nightmare. It's easy to come up quick with some results, but than to go all the way is a proper nightmare. It's WEEKS that I stuck with zooming either for PDFs or images. Let's start with the pdf, I've got a pdf that's loaded in a UIWebView thats loaded in a UIScrollView thats loaded in a UIViewController. Displays ok, it's already zoomed (why? where to set it? Where's the docs?), now when I zoom it doesn't redrawn to sharpen, it zooms to blurry oblivion. Here's my code:
    scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    myWebView = [[DAUIWebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    NSURL* urlLocation = [NSURL fileURLWithPath:theURL];
    myWebView.contentMode = UIViewContentModeScaleAspectFit;
    myWebView.autoresizingMask = ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    [myWebView loadRequest:[NSURLRequest requestWithURL:urlLocation]];
    scrollView.contentMode = UIViewContentModeScaleAspectFit;
    scrollView.autoresizingMask = ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    scrollView.maximumZoomScale = 2.0;
    scrollView.minimumZoomScale = 1;
    scrollView.clipsToBounds = YES;
    scrollView.delegate = self;
    [scrollView addSubview:myWebView];
    DAUIViewController* viewController = [[DAUIViewController alloc]init];
    [[viewController view]addSubview:scrollView];
    [[self navigationController] pushViewController:viewController animated:YES];
    - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return myWebView;
    I've also tried with :
    - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale{
    [myWebView reload];
    Message was edited by: Michael Fuhrmann
    Message was edited by: Michael Fuhrmann
    Message was edited by: Michael Fuhrmann
    Message was edited by: Michael Fuhrmann
    Message was edited by: Michael Fuhrmann
    Message was edited by: Michael Fuhrmann

    Well you cannot get everything that is shown there, as informed by Dave. But some part of it can be achieved by PDF Portfolios. There are some layouts available in Acrobat or you can also get some from internet. You can use this link to get more information about PDF Portfolios:
    http://help.adobe.com/en_US/acrobat/pro/using/WS8AC2CE72-864F-4d65-815A-4AFCAB0B46FA.html
    If you want to watch some videos, use this link:
    http://tv.adobe.com/watch/acrobat-x/what-is-a-pdf-portfolio/
    ~Sandeep V.

  • UIWebView not displaying my website !!?

    Greeting to all developers,,
    i have make my first application using UIWebView,, it  is simple application just to display a webpage
    i have made a webpage and publish it in the internet using Sencha Touch http://www.sencha.com/products/touch
    unfortunately all websites working fine, except my website (http://www.itrack21.com/itrack21mobile)
    also the application open the website in iPad simulator, but not opening the website in iPhone simulator !!
    i have attached the project files for your review .. (http://www.mediafire.com/?hm0v153bk81m5nm)
    Many thanks for your cooperation
    best regards,

    Hi ,,
    I think there is a problem ,, the screen below should appear not the image that you post it
    can any one recognize what is the problem please !!?
    this is the website check it in the browser (http://itrack21.com/itrack21mobile)

  • Saving Images to Device

    I would like grab some images via HTTP from some web site and store them on the device, so that I can call them up later in my UIWebView with .
    Would something like this be possible? Any suggestions in getting started would be appreciated.
    Thanks,
    Jimmy

    s0undz wrote:
    If I save my images to the Documents directory, will I be able to display my images in the UIWebView like this:
    <img src="abcd.jpg">
    Not unless you set the baseURL
    Or is there some special file:// path I need to use?
    Build a file URL like this:
    NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    // NSLog(@"documentPath=%@", documentPath);
    NSString *saveDirectory = [documentPath objectAtIndex:0];
    NSString *finalPath = [saveDirectory stringByAppendingPathComponent:@"Image.png"];
    // NSLog(@"finalPath=%@", finalPath);
    NSURL *imageURL = [NSURL fileURLWithPath:finalPath];
    // NSLog(@"[imageURL absoluteString]=%@", [imageURL absoluteString]);
    I borrowed the above from a nice tutorial that shows how build a class for viewing local documents in general: [http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/16552-pdf-viewer-tutori al.html]. Be sure to use those NSLogs. Don't expect to see an image in your web view on the first try, ok?
    - Ray

  • Does UIWebView support WebResourceLoadDelegate

    I want to get details on the resources that WebKit loads during a page load. I don't think the iphone UIWebView supports all the delegate protocols that WebView does because when I add the delegate methods to my code, they get an error because they cant find (WebView *) For example, I add:
    - (id) webView : (WebView *) sender identifierForInitialRequest : (NSURLRequest *) request fromDataSource : (id) dataSource {
    and it fails obviously , because I'm using UIWebView. Changing (WebView*) to (UIWebView*) compiles fine, but the method is never called.
    I'm trying to make an internal copy of a web page as I read it using UIWebView. I need to capture all of the image files so that I can reproduce the original html file when I am offline. Any ideas how to do that? I was going to use the WebResourceLoadDelegate to capture the image file URL's and the actual image files...but I don't know if I can...

    I am also interested in the answer to this. Has anybody been able to do this using UIWebView?

  • Flash Images and text fading in and out

    Hey Guys,
    Well this is my first post here, hopefully I'm in the right
    section, so here it goes...
    I mainly design websites using Dreamweaver, and I use
    Photoshop and Fireworks to make graphics. I'm making revisions to
    my site, and I wanted to add some animation. I was googleing for
    some inspiration and found this SWF file:
    http://spineandsports.com/swf/banner.swf
    I basically want to know how this was created, so that I can
    "put my own twist on it"
    I know this has to be a simple concept, because I see it done
    a lot in modern site designs today...
    I've played around with Flash a little bit, so I'm familiar
    with the interface, basic tweening, creating symbols stuff like
    that
    Any ideas, interpretations, would be appreciated!
    If any of you could walk me through this process, that would
    be awesome.. My Email is: [email protected]
    Oh, and I'm using Flash 8 Pro on OS X
    Thanks guys.

    Hi Mindus -
    tiff is supported by UIImage, so all you need to do is add the file to your project and drag it onto a content view or UIImageView object in IB, or make a UIImage object in code using imageWithContentsOfFile:.
    Text files may be loaded into a NSString object using a method such as stringWithContentsOfFile:encoding:error: and setting the text property of a UITextView object to the string.
    However, if your objective is to compose text and images on the fly, UIWebView is the only reasonable choice.
    I think UIWebView doesn't support to display images is in tiff format.
    Where did you learn that? Have you tried to display the same html with UIWebView and just changed an image reference from jpeg to tiff? All the UIKit classes make use of the same Core Graphics framework, and CG supports tiff (see Supported Image Formats in the +iPhone Application Programming Guide+. There might be more online discussions about iPhone problems with tiff compared to other file formats. I think user complaints about email attachments have added to the buzz about security weaknesses. Do we think MS has figured out a way to generate faxes that can't be read on an iPhone? Who among us could believe such a ridiculous, paranoid delusion?
    Anyway as above, if you need to compose pages dynamically, running away from UIWebView is not the solution.
    Hope that helps!
    \- Ray

  • UIWebView and https URLs

    Hi guys,
    I'll make this very short.
    If a URL that you want a UIWebView to load is https and would put up an authorization dialog in Safari, what's the best API to use to accomplish this? (I can supply the authentication programmatically).
    All I need is a point in the right direction - there is URLLoading, and several other APIs. I just want the most straightforward one for simply supplying the authentication and then getting the URL to load into a WebView.
    Much thanks,
    Johnny

    So on your localhost, this works fine.. its only when you've uploaded it to your production or remote server that you get these problems ?
    I'd talk to the host of the box.. is there a firewall issue here. Do a view source on the http and https versions of the same pages and double check that the paths are the same. Are there frames in the application which could foul things up ?
    Are you SURE you've uploaded all the images etc that you need ?

  • [iPhone] large table view (500+ elements), each cell with a UIWebView

    Hello, all ...
    I'm developing an application that has to show a table view with 500 (or more) elements in it. Each element has a UIWebView that has to load an image (50x50 pixels in PNG format) from a web server. What i'm finding is that, when this table view is displayed, most of the images don't show up, though a few of them do. I've verified that all of the images are indeed on the web server, but I think that most of the requests fail (perhaps to too many of them going on at once?). Furthermore, the table sometimes scrolls very rough i.e. when an upcoming cell is loading its' image.
    Other iPhone apps seem to do the UIWebView-in-a-cell thing pretty well i.e. Facebook. In the Facebook iPhone app, the table scrolls smoothly, and the images display as they're loaded. How can I make my app behave similarly?
    Regards,
    John
    Falling You - exploring the beauty of voice and sound
    http://www.fallingyou.com

    Hmm ... something still isn't right. The scroll view still scrolls very jerkily, and the reason seems to be that I don't know which delegate method to override to detect when scrolling has finished. I tried overriding -scrollViewDidScroll, like so:
    - (void)scrollViewDidScroll:(UIScrollView *)scrollViewDidScroll
    AlbumViewCell *firstAlbumShown = (AlbumViewCell *)([[self.tableView visibleCells] objectAtIndex:0]);
    AlbumViewCell *lastAlbumShown = (AlbumViewCell *)([[self.tableView visibleCells] lastObject]);
    NSLog(@"scroll view finished scrolling ... first row is %s:%s and the last is %s:%s",
    [[[firstAlbumShown album] albumname] UTF8String],
    [[[firstAlbumShown album] artist] UTF8String],
    [[[lastAlbumShown album] albumname] UTF8String],
    [[[lastAlbumShown album] artist] UTF8String]);
    for (int count = 0; count < [[self.tableView visibleCells] count]; count ++)
    [[[self.tableView visibleCells] objectAtIndex:count] displayAlbumArt];
    ... but when I make one swipe with my finger to scroll the view, I see this in the console log:
    2008-10-21 15:43:52.051 Magnatune[3160:20b] scroll view finished scrolling ... first row is 14 Days:Plunkett and the last is A Celtic Celebration:Da Camera
    2008-10-21 15:43:52.637 Magnatune[3160:20b] scroll view finished scrolling ... first row is 5 and 6 part Fantasies of William Lawes:Oberlin Consort of Viols and the last is Acoustic Abstracts:Heavy Mellow
    2008-10-21 15:43:53.376 Magnatune[3160:20b] scroll view finished scrolling ... first row is Airs De Cour Francais Du XVIIe Siecle:Trio Dafne and the last is Alpha and Oranges:Atomic Opera
    2008-10-21 15:43:54.247 Magnatune[3160:20b] scroll view finished scrolling ... first row is Ambient Excursions:Stargarden and the last is Apa Ya:The Headroom Project
    2008-10-21 15:43:55.041 Magnatune[3160:20b] scroll view finished scrolling ... first row is Ashek:Tim Rayborn and the last is Back with Bach:Ralph Rousseau Meulenbroeks
    2008-10-21 15:43:56.002 Magnatune[3160:20b] scroll view finished scrolling ... first row is Azadi:Junoon and the last is Balance:Solace
    2008-10-21 15:43:56.581 Magnatune[3160:20b] scroll view finished scrolling ... first row is Azadi:Junoon and the last is Balance:Solace
    i.e. -scrollViewDidScroll was called multiple times, even though I only swiped once. I just want to know when the scrolling has truly and completely stopped, so I can tell the visible cells to draw their album art. Which delegate method do I override?
    Regards,
    John
    Falling You - exploring the beauty of voice and sound
    http://www.fallingyou.com

  • Uiwebview player status bar problem

    Hi There,
    Iam facing a problem when I play a video on UIWebView,
    as the webView starts the player playing the video the player tool bar hides if the user dont touch screen for few secounds, at that time if the device is rotated to different orientation and then press done to exit the full screen mode, the existing webview goes and sits inside the staus bar as show in the image.
    can anyone get back to me on this.
    Regards
    Vinodh

    Are you mentioning the screensizes on the right bottom of the document window (Refer the below screenshot)

Maybe you are looking for

  • No files will open in PS in CS2 nor trial version CS5

    Up to a month ago my PS CS2 was working great.  Then one day I found I could not open any files in the program. I tried reloading preferences with no change.  I then removed and reloaded the program (Creative Suite CS2), and PS worked great for two d

  • Having issue with texting my contacts after 4.1 update...HELP!!!!!

    Everything was fine with my phone, but after the 4.1 update, i began to have issues...I go to my contacts, select Brian, text him, then immediately or later on in the day (does not matter) i want to text Nicole..i go to contacts, select Nicole, but B

  • Overhead user exit (COOM0001) not being triggered for specific plant

    Hello all, I was wondering if anyone came across this situation before. I activated user exit COOM0001 for overhead calculation. This user exit is triggered when I create PCE for plant A but not plant B. I can't figure out why it is not being trigger

  • Missing Disks

    Help! When trying to open FCP I get this error message: "To preserve the integrity of the data used by FCP, it is necessary to ensure the existence of the following paths: 'Unknown' is offline." Then it gives me the options to Quit, Check Again, or R

  • Solaris 8 projects strange behavior

    Hello, it looks like an offtopic a bit, but I found this forum the most close to my post theme. I have some strange problems with sol8 projects: for many hosts that mechanism works OK, but for some users on some boxes, especially for oracle processes