Search code examples
iphoneuitableviewthree20

TTTableImageItem doesn't load the image until scroll


I'm using the three20 project for my iPhone app. I've narrowed my problem down and I'm now just trying to re-create the 'Web Images in Table' example that comes with the project. I've copied the code exactly as in the project, with the exception that I do not use the TTNavigator (which the example does) but I am adding my TTTableViewController manually to a tabBar.

The problem is as follows; the images in the table should load automatically from the web, like in the example. But they only load after I scroll the table up and down.

In the console it clearly says it is downloading the images, and you see the activity indicator spinning like forever.. And unless I scroll up and down once, the images will never appear.

Anyone? Thanks in advance.

P.S: If I'm using this code in any random UIView, It also doesn't work (only shows a black square):

TTImageView* imageView = [[[TTImageView alloc] initWithFrame:CGRectMake(30, 30, 100, 100)] autorelease];
imageView.autoresizesToImage = YES;
imageView.URL = @"http://webpimp.nl/logo.png";
[self.view addSubview:imageView];

If I put this code in my AppDelegate (right onto the window), it does work .. strange?

POSSIBLE SOLUTION: Although I stopped using TTImageView for this purpose, I do think I found out what the problem was; threading (hence accepting the answer of Deniz Mert Edincik). If I started the asynchronous download (because basically that is all the TTImageView is, an asynchronous download) from anywhere BUT the main thread, it would not start. If I started the download on the main thread, it would start immediately..


Solution

  • Sounds like a threading problem to me, are you creating TTImageView in the main runloop?