Я пытаюсь отобразить UIImageView внутри UITableViewCell.
Внутренний метод - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
У меня есть:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
CGSize cellSize = cell.frame.size;
CGFloat cellWidth = cellSize.width;
CGFloat cellHeight = cellSize.height;
CGRect imageFrame = CGRectMake(0, 0, 70, cellHeight);
UIImageView * image = [[UIImageView alloc] initWithFrame:imageFrame];
[image setImage:[UIImage imageWithContentsOfFile:@"cyan.jpg"]];
CGRect nameFrame = CGRectMake(80, 0, cellWidth-80, cellHeight/2);
UILabel * nameLabel = [[UILabel alloc] initWithFrame:nameFrame];
nameLabel.text = @"Name: John Doe";
CGRect jobFrame = CGRectMake(80, 20, cellWidth-80, cellHeight/2);
UILabel * jobLabel = [[UILabel alloc] initWithFrame:jobFrame];
jobLabel.text = @"Job: IT-Consultant";
[cell addSubview:image];
[cell addSubview:nameLabel];
[cell addSubview:jobLabel];
return cell;
}
Ярлыки отображаются отлично, но я не вижуimage.
Любая помощь будет оценена.