Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-04-2008, 05:17 AM   #1 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 4
Default [TableViewCell] Image with content of url

Hi everyone,

I'd like to know how can i load an image from an url into a tableviewcell ? I tried the following code :
Code:
NSURL *url = [NSURL URLWithString:@"http://xxx.xxx.xx/xx.png"]
NSData *imageData = [NSData dataWithContentsOfURL:url];
myCell.image = [UIImage alloc] imageWithData:imageData];
the thing is when i scroll the tableview, it's getting very slow, so i think that this is not the good way to show an image from an url...? if someone can help me pleaz...

thanks
dim971 is offline   Reply With Quote
Old 09-04-2008, 05:28 AM   #2 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

It certainly is very expensive to use images in that way. You are also adding to the RAM by demaning the images be held by the OS. When they are referenced from WITHIN the app, they aren't held in ram till they are required. Here, when the table view is created, it references them immediately and takes mega RAM.

Make sense?
DevTeamOfOne is offline   Reply With Quote
Old 09-04-2008, 05:47 AM   #3 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 4
Default

Quote:
Originally Posted by DevTeamOfOne View Post
It certainly is very expensive to use images in that way. You are also adding to the RAM by demaning the images be held by the OS. When they are referenced from WITHIN the app, they aren't held in ram till they are required. Here, when the table view is created, it references them immediately and takes mega RAM.

Make sense?
Okay, thank you :-)
so how can i display an image from an web url in a tablviewcell ?
dim971 is offline   Reply With Quote
Old 09-04-2008, 06:40 AM   #4 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 75
Default

you can check out the following

UIImageView in a custom cell | Iphone Noob

There is also an entry to create a custom cell, but there is source there to look at.

I am doing it by subclassing uitableviewcell and then drawing a uiimageview on my custom cell
__________________
Iphone Noob iPhone Development Blog. Learn to develop for the iPhone SDK with me
hijinks is offline   Reply With Quote
Old 09-04-2008, 09:05 AM   #5 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 4
Default

ok, thank you all, it works :-) but there's one thing i didn't quite understand : first i have a table view, then i put a custom view on the first header with an image view inside the view. The image is getting from a web url using [NSData dataWithContentOfURL:url]. When i do this, the scrolling of the table view is very slow (as DevTeamOfOne explain :-), but if i use a custom tableviewcell with the image setting with [NSData dataWithContentOfURL:url], the scrolling is normal...why ? (hope my explanation is clear enought :-)
dim971 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 468
13 members and 455 guests
dana0550, dapis, darbsllim, Domele, dre, EdwardMichel, Harolano, HowEver, ilmman, lbert, leesdesjardins, marshusensei, Objective Zero
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 157,851
Threads: 88,914
Posts: 379,296
Top Poster: BrianSlick (7,072)
Welcome to our newest member, darbsllim
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:16 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0