Reputation: 7921
i've problems with the scroll of my Table View. I have a custom cell that i load with this code :
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"CustomCellQuartieri" owner:self options:NULL];
cell=customCell;
}
This is the code. customCell is an UITableViewCell object with a own xib. The controller of the xib is my view controller where the table is placed in. I load 2 label and one imageView from the internet. What is the problem? And how can i make my custom cell reusable? Thanks
Upvotes: 0
Views: 328
Reputation: 7921
The problem was that images have to be loaded asynchronously. Search SDWebImages on Google.
Upvotes: 0
Reputation: 5611
Since you are using a custom UITableViewCell
you have to set the identifier string property through Interface Builder, and then dequeue the cell in the usual way, using that same string as the key. This way your app will not create a new cell for each row of the table, but will reuse the already present cells, reducing build and presentation times.
If this won't fix the issue, you should look at the internet connection, to understand why data loading is so slow. If you own the server that serves the data, you would try to speed it up, otherwise you should look for a different or more efficient way for loading data remotely. Some code example would be great.
As stated in the comments, the slowness could be related to the loading time of remote images. You could try to build a local dictionary, of something similar, in which you'll save the images you already loaded associating them to their URL as the key, while you'll read remotely those you still don't own. This will work like a local cache to improve loading time for remote data.
Upvotes: 0
Reputation: 69499
To make your custom cell reusable, set the identifier propertie in Interface Builder.
Who do you load the data from the internet (Async)?
Upvotes: 1