0

I'm new in Xcode Programming and I'm developing a small application but I have a problem.

I have a Table View with a Custom Cell, taking externally the data to populate the view (by JSon). I have a big slow navigation in list because in the method - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath. I get an external image and this makes it all slow because it runs every time a cell displayed.

How can I populate the entire list without using this method? Or is there an alternative to make it understand that the image exists?

ronalchn
  • 12,225
  • 10
  • 51
  • 61
Skiddolo
  • 23
  • 3

1 Answers1

0

There are few methods Apple suggests when customizing your UITableViewCell. You probably is trying to add subviews to the contentView of the cell. A better approach is described here Subclassing UITableViewCell. Well, I suggest you read the TableView Programming guide.

rptony
  • 1,024
  • 1
  • 12
  • 22
  • I understood thats what you are trying. It reuses the image. Instead of adding subviews to the contentView you can try the third method apple suggests. Make a custom view and lay out your UI Elements as subviews to the custom view. The custom view will go in as a subview for your cell's content view. You have better control for encapsulation by adopting this style – rptony Sep 19 '12 at 15:02
  • my problem probably derive from this string "[tableView dequeueReusableCellWithIdentifier:CellIdentifier];"...Apple suggests to reuse a cell and in this case when i load a remote image for a single cell, it load the same image for other "reuse" cell and this make my list slowly...this is my code - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { Cell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; [cell.img setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:url]]];return cell; } – Skiddolo Sep 19 '12 at 15:04
  • do you have an example?refering to apple guide, you mean "Customizing Cells" block? – Skiddolo Sep 19 '12 at 15:07
  • http://developer.apple.com/library/ios/samplecode/TableViewSuite/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007318 – rptony Sep 19 '12 at 15:09
  • those example are not update to storyboard, i don't want to change everything without storyboard :( however i don't have a subclass..i make a custom cell, put in an UIImageView e some UILbale, create a UITableViewCell for this item and set the cell item from code write before..some idea? – Skiddolo Sep 19 '12 at 15:38