iPhone : Problem while displaying captured image in UIWebView - iphone

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.

Related

TTStyledTextLabel loading a web image inside a UITableViewCell

I have TTStyledTextLabel inside a UITableViewCell. The label loads a HTML string with references to web image resources. The problem I am facing is that once the image has been loaded the dimensions of the label need to be changed and hence the UITableViewCell.
Any idea as to how this should be done.
Would appreciate any help. This has consumed a lot of my time.
Here is how I did it.
I scanned for all the text to see what images have to be downloaded. Once the images have been identified, i initiated their download using TTURLRequest. After the images were downloaded the sizeThatFits api returns the correct height.
This way is a bit slow, but solves the problem, until I am able to figure out a better way.

how to load the pdf through programming with animation in iphone

how load a pdf into iphone and my pdf is of 200 pages then it should allow to turn the pages as we do with while reading book manually means use animation to turn a page one by one ..
Thanking you ..
Loading a large PDF and having page flipping animation isn't very simple. You can use a UIWebView like #Jim says to load the entire thing by just pointing the UIWebView's URL to the PDF but you won't get page animation. However to get full control requires that you render the PDF page by page manually to a view, and create the view's turning animation your self. Its nontrivial, and given your question you don't sound like you know enough to realistically achieve this right off.
Use UIWebView Control to load pdf files.

How to get WebView Content Size

I am looking to find WebView content size to scale data to fit into small size of WebView Frame.
WebView is continuous loading data as getting images from IP Camera so -(void)webViewDidFinishLoad delegate method is not called, otherwise [webview sizeThatFits:CGSizeZero] would give receiver content size.
How to get WebView content size which is continuous loading data ?
Thanks,
See my answer to a similar question. Instead of -webViewDidFinishLoad you should consider calling this using a timer (and checking whether something has been loaded, first).
If the HTML is under your control, you might wanna call it using a JavaScipt onLoad handler that tries to fetch a custom URL that you can intercept in -webView:shouldStartLoadWithRequest:navigationType:.

Preloading images from URL in TableViewCell

I'm making a simple rss reader for the iPhone. The feed (http://feeds.feedburner.com/foksuk/gLTI) contains a reference to images that I want to show in my TableView.
By default, as far as I understand, the iPhone only tries to load images when they are needed: it will only load the images for the rows that are displayed. Only when the user scrolls down, it will start loading the ones that need to be displayed. Right?
Now, since the images are downloaded from the web (they are not too large, but still), the scrolling of my TableView is stuttering. This is in the emulator, so on the device itself it will only be worse.
Luckily, this specific feed only lists the latest 12 entries of the blog. So I guess I should be able to first download an cache all the images, so they can be loaded from the memory, rather than from the URL.
What is the proper approach here?
I had the same problem, where my TableView would have to download each image before it displayed the cell. Like you say, it causes a big slowdown in the scrolling speed. What you need to do is download the images in the background and then insert them into the cell when they're finished downloading. This is how the app store app does it.
This post has all you need to know, including a class file you can use straight away:
http://www.markj.net/iphone-asynchronous-table-image/

Lazy load images in UITableViewCell

I have some 50 custom cells in my UITableView. I want to display an image and a label in the cells where I get the images from URLs.
I want to do a lazy load of images so the UI does not freeze up while the images are being loaded. I tried getting the images in separate threads but I have to load each image every time a cell becomes visible again (Otherwise reuse of cells shows old images)
Apps like Facebook load images only for cells currently visible and once the images are loaded, they are not loaded again. Can someone please tell me how to duplicate this behavior.
Thanks.
Edit
Trying to cache images in an NSMutableDictionary object creates problems when the user scrolls fast. I am getting images only when scrolling completely stops and clearing out the cache on memory warning. But the app invariably gets a memory warning (due to size of images being cached) and clears the cache before reloading. If scrolling is very fast, it crashes.
Any other suggestions are welcome
Loading the images on a background thread is still a good idea. If you didn't want to reload them each time, I'd suggest setting up an NSMutableDictionary and storing the images in there. You could use some unique identifier, like the row ID or even the name of the image, as the key for each image.
When loading a cell, you'd send an objectForKey: message to the NSMutableDictionary to retrieve the image for that particular cell (based on your unique key for it). If it returns nil, that means that the image is missing from the cache and you need your background image loading thread to go retrieve it. Otherwise, you will get back the appropriate image for your table cell to display. On a memory warning, you could clear out this cache of images with no adverse effects (aside from forcing them to be reloaded again on demand).
I have just successfully tackled the same problem by using a custom NSOperation to load the images in a queing fasion and stored them into a static NSMutableDictionary as a cache. Below is a link to the basis of the code I used to solve the problem.
Loading remote images for UITableViewCell
Best to read all the threads in the forum to help you understand what's actually going on.
lostInTransit,
I am having a similar problem and while exploring the many different possible solutions I found this blog post:
davidgolightly.blogspot.com/2009/02/asynchronous-image-caching-with-iphone.html
I would also suggest that you download the URLCache sample from the apple developer website:
developer.apple.com/iphone/prerelease/library/samplecode/URLCache/
And here is another post on the problem:
www.markj.net/iphone-asynchronous-table-image/
I'd love you to share your findings as well.
Lazy loading is like synchronous type request.. means wait for respond
ego image button is solution for that..
ego image button is asynchronous type request..don't wait for respond..just display data at a time....
you can download folder from github....
add to your project...
in xib..at image view ,change class to ego image button...
make object of it in m file...
you can use.....
For those who are interested, and are lazy like me, I would like to suggest an open source (MIT license) implementation of lazy/cached network of UIImageView images: SDWebImage
UITableView with image caching and resizing/setting in background thread:
http://blog.slaunchaman.com/2011/08/12/gcd-example-updated-now-with-more-speed/
This is Tutorial about NSOperation with example that show how to Lazy load images in UITableViewCell