Я сталкиваюсь с этой очень странной проблемой, я создал пользовательский UITableViewCell, на котором у меня UIImageView слева и справа, у меня два UILabel.
Когда я запускаю программу, я вижу все изображение и на столе появляется ярлык.
У меня всего 5 строк, которые нужно отобразить
Единственная проблема заключается в том, что изображение начинает отображаться со строки 2 и переходит в строку 6, где по мере появления меток отображается строка 1 в строку 5.
Пользовательский файл UITableViewCell .h
@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;
И UITableViewController, который использует это
- (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;
}