Hi,
I am facing this very weird problem, I have created a custom UITableViewCell on which I have a UIImageView on the left and on the right I have two UILabel.
When I run the program, I see all the image and the label appears on the table.
I have total of 5 rows that needs to be displayed
The only problem is the image starts displaying from the row 2 and goes upto row 6 where as the labels get displayed from row 1 to row 5.
Custom UITableViewCell .h file
@interface ProductViewCell : UITableViewCell {
IBOutlet UILabel *titleLabel;
IBOutlet UILabel *detailLabel;
IBOutlet UIImageView *imageView;
}
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *detailLabel;
@property (nonatomic, retain) UIImageView *imageView;
And the UITableViewController that uses this is
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
ProductViewCell *cell = (ProductViewCell*)[tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle]
loadNibNamed:@"ProductViewCell" owner:self options:nil];
for(id currentObject in topLevelObjects){
if([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (ProductViewCell *) currentObject;
break;
}
}
}
NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
cell.titleLabel.text = [dictionary objectForKey:@"name"];
cell.detailLabel.text = @"";
cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString: [dictionary objectForKey:@"imageUrl"]]]];
return cell;
}