Hi,
I have a NSArray and an UITableViewCell.
In my NSArray I have 4 objects which I want them into the UITableViewCell with 4 images near each cell.
From some reason, in the UITableViewCell, only the fourth and the last image appears. What should I do?
*The UITableViewCell is actually UIPopoverController
Here's my code:
Thanks!
I have a NSArray and an UITableViewCell.
In my NSArray I have 4 objects which I want them into the UITableViewCell with 4 images near each cell.
From some reason, in the UITableViewCell, only the fourth and the last image appears. What should I do?
*The UITableViewCell is actually UIPopoverController
Here's my code:
Code:
- (void)viewDidLoad {
[super viewDidLoad];
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
self.myArray = [NSArray arrayWithObjects:@"Object One", @"Object Two", @"Object Three", @"Object Four", nil];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CellIdentifier";
self.cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
}
cell.textLabel.text = [self.myArray objectAtIndex:indexPath.row];
if ([myArray objectAtIndex:0]) {
UIImage *googleIcon = [UIImage imageNamed:@"Image 0.png"];
cell.imageView.image = googleIcon;
}
if ([myArray objectAtIndex:1]) {
UIImage *yahooIcon = [UIImage imageNamed:@"Image 1.png"];
cell.imageView.image = yahooIcon;
}
if ([myArray objectAtIndex:2]) {
UIImage *bingIcon = [UIImage imageNamed:@"Image 2.png"];
cell.imageView.image = bingIcon;
}
if ([myArray objectAtIndex:3]) {
UIImage *askIcon = [UIImage imageNamed:@"Image 3.png"];
cell.imageView.image = askIcon;
}
return cell;
}
}
Thanks!