问题描述
|
我有不同大小的图像要输入为表格视图的缩略图,有没有办法使所有图像对齐,尽管它们的大小不同?因为在我的情况下,文本的位置将跟随图像,因此不会整齐。
这是我用来输入图像的代码
static Nsstring *CellIdentifier = @\"Cell\";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.textLabel.text = title;
cell.textLabel.adjustsFontSizetoFitWidth = YES;
cell.imageView.image = thumb;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
解决方法
您可以随时设置
imageView
和textLabel
对象的框架。
,Cell.imageView是一个UIImageView,它是UIView的子类。查看UIView的文档-恰好\“配置调整大小行为\”。也许有些帮助。
但要注意-动态调整大小可以减少tableview的滚动行为。也许更好的方法是在实际在tableview中使用图像之前,调整图像的大小以适合uiimageview的大小。