I am grabbing my image from a webservice and pasting it into my app. The webservice saves the image as img.jpg. I wanted to change the picture to a different one so I got another one and saved the picture in the same spot to img.jpg. It overwrote the file
When I look in my webservice the picture is the new one. I retrieve the image with AsyncImageView like so:
[AsyncImageLoader sharedLoader] cancelLoadingURL:logoView.imageURL];
logoView.imageURL=[NSURL URLWithString:logourl];
The logourl is filled with the proper url but it isn't grabbing the new image. It is keeping the old image there.
How can I clear that old image and use the new one?
You have to remove the old image from the cache, because the URL is the same for both images the ImageLoader thinks they are the same.
[[AsyncImageCache sharedCache] removeImageForURL:logoView.imageURL];
EDIT:
Seems like my code was from an older version of AsyncImageLoader
Try this:
[[AsyncImageLoader defaultCache] removeObjectForKey:logoView.imageURL];
//Make sure logoView.imageURL is a NSURL
Related
I have a function that retrieves some images from a JSON feed using NSURLConnection. My connectionDidFinishLoading retrieves an array with all the data for that image (including the URL of the image).
What's the best way to display that image on a UIImageView? Even though the URL is being retrieved, I am pretty sure I would still have to display the image in a connection-friendly manner?
Thank you,
As per your requirement Images must be display in connection friendly manner. Then you can go for Image cacheing which requires image URLs. For your best understanding see this link and this link.
for asynchronous image downloading try with this link.
My situation is that I am making a uitableviewcontroller with uitableviewcells having a thumb nail or picture on the left, text on the right. All data is stored in a remote server. I have made a php to communicate with backend batabase and generate JSON to pass the data to iphone through http. However, I don't know how to do the same thing to photos. Please suggest me someway to do it. Thanks!
As Mundi said it already.
And make sure that you load them asynchronously.
There is a nice tutorial on this page:
http://www.markj.net/iphone-asynchronous-table-image/
I assume you are using NSURLConnection to fetch your data from the server. Do this:
Collect the photo data into an NSData object.
In the didFinishLoading method use this to create the images:
UIImage *thumbnailImage = [[UIImage alloc] initWithData:downloadedData];
// don't forget to discard the downloaded Data and release the image
The actual setup of your cells might be more complicated. The way I do it is to check in each call to cellForRowAtIndexPath: if I have cached the image, if not I pass to URL of the image to a NSURLConnection. I keep the open connections in an array and eliminated them when each download finishes or the view disappears. Let me know if you need more hints...
For example, I can convert the second image into NSData and then place it inside metadata inside the first image and then when I open the first image and read the metadata I can get the NSData and turn it into an UIImage.
How would I go about doing this? All the metadata tags I see are not large enough to support another picture. I know picture in picture is quite common on desktop apps so I'm interested in getting it to work on the iPhone.
Is metadata the correct way to do this or is there another way?
I am displaying graph by capturing image and loading into a webView using loadHTMLString method.
The images come fine when displayed the first time. But it does not seem to change when I recapture the image which is different.
Also I have checked that the image name is same and the new image is recaptured every time.
It seems to be some issue with UIWebView reloading.
what could be wrong ?
If the same image with the same name is being captured, it may be cached in the UIWebView, causing it to display as the initial image instead of the updated images. If there's a way to use the reload function of the webview (which, in a browser will often check for updates to images), this might help.
If that doesn't solve it, I'd make sure that you're not somehow saving and appending the captured HTML to a variable, causing the new text to be appended to the end of the variable and not loaded.
I'm new to iphone dev, i'm just trying to get something done.
I do my first XML parser App. When my app launches i set a tableView with a custom cell. There is in the custom cell two labels and one image.
When the table view is launched i call my custom cell method which take the string od the image's adress and then make an url with it, a nsdata from the content of an url than i create my image with the content of this data.
But my table view is really really slow even on simulator.
what is the best way to display images on iphone via the internet ? ?
i know they have to be in a png format but even with png it is too slow
thanks for all
i use :
> NSURL *imgUrl = [NSURL URLWithString:_text];
> NSData *imgData = [NSData dataWithContentsOfURL:imgUrl];
> limage.image = [UIImage imageWithData:imgData];
Is your image saved at its final resolution? Say you want to display a 25x25 pixel image in the table, is the file saved as a 25x25 image or is it saved as some higher resolution? This will cause some slowness. However you should be loading the image in a background thread so that when scrolling the scrolling isn't holding up waiting for the image to load. Remember that doing network transfer to get the image is most likely the longest part of the process. You should also cache the image in some way instead of just assigning the image to the limage.image property. This way it won't redownload the image each time it redraws the cell.
Edit
Also you don't have to use PNG images for the pictures in the table cells. You can use regular JPG or GIF images if you want. The image format used should be what ever format is appropriate for the type of image content you will have. You only have to use PNGs for the icons, and splash screens, although it is preferred to use PNG in all embedded resources.
[NSData dataWithContentsOfURL:imgUrl];
Will certainly slow your app down since it will wait for your image to be done loading, called a synchronous call. What you really want is asynchronous calls for fetching the content of the image.
Have a look at http://joehewitt.com/post/the-three20-project/ where you'll find an nice subclass of UIImage that supports handling loading of images by url.