ios - UITableViewCell imageView 重叠单元格中的文本

标签 ios objective-c uitableview

我有一个单元格,里面有一些文本,我正在尝试向单元格添加图像。

这是我试过的:

UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 30, 30)];
imageView.backgroundColor = [UIColor clearColor];
[imageView.layer setCornerRadius:5.0f];
[imageView.layer setMasksToBounds:YES];
[imageView setImage:[UIImage imageNamed:@"test2.jpeg"]];
[cell.contentView addSubview:imageView];
cell.imageView.clipsToBounds = YES;

这是现在的样子:

enter image description here

有没有办法避免图像与单元格中的文本重叠?提前致谢!

最佳答案

tableviewcells 有自己的 imageView,将显示在内容的左侧或至少显示在单元格文本的左侧。

您正在创建一个恰好具有相同名称的额外 imageView。

关于ios - UITableViewCell imageView 重叠单元格中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20863232/

相关文章:

c++ - 返回对本地临时对象的引用

ios - 自定义 UITableViewCell 选中时不显示内容

ios - 在 swift 3 中子类化的 UITableViewCell 始终具有 320 点的 contentView

ios - Tableview 中的 CollectionView,数据源错误

ios - 在 iOS 设备上打开 p12 文件

iphone - iOS 中缓存的 NSURLRequest 内存大小

iphone - IOS:长按选择UICollectionView Cell

iphone - 如何将值传递给另一个 View Controller ?

ios - 使用单个 XIB 和类创建多个 Collection View 单元

ios - Swift:展开导致swift编译缓慢