Мое понимание состоит в том, что для отображения аксессуаров с изображением вам нужно изменить pathForRowWithIndex Path.ios/xcode/objective-c: Как создать аксессуар с изображением в пользовательской ячейке?
Основываясь на различных учебниках и вопросах в SO, я бросил все, но кухня погрузилась в этот метод. Некоторые говорят, что вам нужно включить только аксессуар. Другие говорят, что вам нужна кнопка. Несмотря на это, изображение все еще не отображается.
Мне также сказали, что проблема не в раскадровке, как в одном из видов аксессуаров на складе, и нет.
Можно ли рекомендовать безошибочный способ получить изображение для отображения в представлении аксессуаров:
Вот метод, который я пытался без успеха:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
// UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// cell.selectionStyle = UITableViewCellSelectionStyleBlue;
IDContactImport *contactImport = self.contacts[indexPath.row];
IDTableViewCell *idTableCell =(IDTableViewCell *)cell;
idTableCell.contactImport=contactImport;
if (contactImport.imageData==nil)
{
idTableCell.iconView.image = [UIImage imageNamed:@"headshot.jpg"];
}
else{
idTableCell.iconView.image = [UIImage imageWithData:contactImport.imageData];
}
UIImage *image = [UIImage imageNamed:@"checked.gif"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
button.frame = frame;
[button setBackgroundImage:image forState:UIControlStateNormal];
[button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];
button.backgroundColor = [UIColor clearColor];
cell.accessoryView = button;
NSLog(@"Trying to load accessory image");
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checked.gif"]];
cell.accessoryView = imageView;
// UIImage *image = [UIImage imageNamed:@"headshot.jpg"];
// UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
// CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
button.frame = frame;
[button setBackgroundImage:image forState:UIControlStateNormal];
[button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];
button.backgroundColor = [UIColor clearColor];
cell.accessoryView = button;
return cell;
}
Не работает. И это сводит меня с ума ... теперь около недели я застрял на этом. Может ли что-то вмешиваться в него, например, настройки раскадровки или что-то в дизайне ячейки? Или мне нужно сделать что-то, что связано с представлением кадра или содержимого? Это специальная ячейка таблицы. –