Quote:
Originally Posted by imsatasia
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