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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-28-2010, 02:23 PM   #2 (permalink)
apiphone
iPhone20
 
Join Date: Sep 2009
Posts: 140
apiphone is on a distinguished road
Default

Quote:
Originally Posted by imsatasia View Post
hello everyone,

I want to load dynamic image in each cell of tableview.

I'm using the following code:

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
		//cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }
    
    
	cell.textLabel.text =[listOfCar objectAtIndex:indexPath.row];
	cell.detailTextLabel.text = @"Last service on 01/20/2009";
	cell.image = [UIImage imageNamed:@"ww.png"];
    cell.textColor = [UIColor whiteColor];
	return cell;
}
to load the image in the cell of tableview.

But, it was showing "ww.png" for each cell.

How can I add dynamic images.?

Code:
listOfCar = [[NSMutableArray alloc] init];
With this code it will show the same image (ww.png) on each row. You have to provide different image name for each row, you can simple write

Code:
if (row == 0)
{
    cell.image = [UIImage imageNamed:@"ww.png"];
}
else if (row == 1)
{
     cell.image = [UIImage imageNamed:@"ww1.png"];
}
Or count the number of rows and have a loop with different row images.
Hope this helps
apiphone is offline   Reply With Quote
 

» Advertisements
» Online Users: 487
17 members and 470 guests
AyClass, baja_yu, Brian965, David-T, djbrooks111, djohnson, Free App Monster, HemiMG, ilmman, kazbluesky, linkmx, mezzh, schaney1403, simplymuzik3, SLIC, sTerrenceTatel, yvonneolivia
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,440
Threads: 94,026
Posts: 402,591
Top Poster: BrianSlick (7,978)
Welcome to our newest member, sTerrenceTatel
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:44 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.