Slow loading of Json data in iphone - iphone

Greetings of the day.
I am having table view where JSON data having text,distance and image is loading very slowly in cells,as i am scrolling down app is getting heavy... but i had seen in some apps that irrespective of image data.... text and distance has been loaded earlier and by activity indicator they are showing that image is loading.
I am not getting how to scroll faster in table view irrespective of image data.
thanx in advance
Software Developer

You may want to read this Apple doc about loading table view cells. I also am loading a UITableView from JSON web data, but what was really slow was the handling and loading of the table cell objects themselves.
It scrolled noticeably faster once I worked in the Apple-recommended cell handling code.

Related

Load more images in UITableView with images using lazy loading

I have a UITableView with images like photo album, images are loading with lazy loading. I want to load more images while scrolling to the bottom of the tableview or when the last row of the table view reached. How can I do this?
UITableView already does lazy loading for you. It will only ask for the visible cells. If you are taking about adding more images to the table while the user is scrolling, you can implement UIScrollViewDelegate methods to calculate the current scrolling position, and when the user reaches certain point, add more images to the NSMutableArray on your datasource.
Check this
http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Introduction/Intro.html
and this Lazy load images in UITableView
You can use SDWebImage.
This library provides a category for UIImageVIew with support for remote images coming from the web.
It provides:
An UIImageView category adding web image and cache management to the Cocoa Touch framework
An asynchronous image downloader
An asynchronous memory + disk image caching with automatic cache expiration handling
A guarantee that the same URL won't be downloaded several times
A guarantee that bogus URLs won't be retried again and again
Performances!

Lazy Loading in UIScrollView with Data from SQLite

In my iPad application, I've made a segmented control and one segment of which -when clicked- displays a long list (about 300) with images and labels from the local SQLite database. This is taking a lot of time to load and puts the app activity to halt while it's loading all of it from the database.
Although I've applied an activity indicator for the time being, but that looks very shoddy. Can anyone tell me how to apply Lazy Loading in a way that When the button is clicked to open that view, instead of loading all the content at once, it fetches only the content that's displayed on the content initially (about 9 images with lablels).
Thanks in advance.
You should implement paging on the list. Load first 25 item and then add button ("Next 25") on tableFooterView, which will load another 25.
If you use a UITableView, you might have a better chance.
A UITableViewCell loads cells one at a time(gives you the index of the item it is trying to load), so if you use a table view, it will only load the number of items that it needs to display. You tell it how many items there are, how tall they are, etc.
It also reuses cells, so it gives a lot better performance than creating 300 different views in memory at a time.
A UIScrollView doesn't know about your "items", so it lets you push as many items as you want into a view, and then adds a scroll bar. No optimization here for memory usage, or database access.

what precautions are required when a UITableView is updating? (e.g. locking it?)

Should one "lock" a UITableView whilst it is updating somehow?
That is, during a data refresh for a UITableView (assuming it takes a few seconds), should one be somehow locking the view itself so that users can't click through on rows etc?
Just wondering what precautions (if any) a developer should take here.
Depends on the context. A common solution, when there’s no guarantee that the contents of the table will still be valid once the load completes, is to cover it with a semitransparent full-screen overlay view displaying an activity indicator or a progress bar. If you’re just loading new data, though—i.e. the old data in the table is still valid, like when you’re refreshing a news feed or similar—there shouldn’t be a need to lock anything.
Set the userInteraction to disabled.
When table is getting updated and its time consuming such as loading numbers of image using url or getting thumbnail of videos playlist or getting data from webservice etc then there is need to use lazy loading of content of in table view cell so there will be no effect of time consuming data in table view as it will be disaplayed when lazy loader has content of data without effecting tableView

how to persist tableview data on vertical scroll

i have created scrollview and have loaded tableview on that programmatically .also i have created customize tableview cell and displaying data in tableview.But my problem is whenever i am scrolling tableview vertically my data is not getting persist and data of cell is getting erase.Please help me how shuld i store that data
It sounds as if you might not be using the reuseidentifiers of the table view properly. If you give all cells the same reuseidentifier then as you scroll the cells that go off screen might end up losing the customizations you made to them. I suggest getting a good understanding of reuseidentifiers, you could start here:iphone-what-are-reuseidentifiers-uitableviewcell

How to load images in uitableview?

In my application i m using webservices to get the the image to load in UITableView. the images loaded in the cell and i scroll down to see other datas, if i again scroll up to see already loaded data, there the loaded images are again loading.
Why this happens. can anyone tell that how to display images in LazyTableImage example
If we scroll, each time cellForRowAtInpdex is called every time.so,you should handle the image loading in someother part(say ViewDidLoad)..