iphone - 是否可以重新定位和调整标准 UITableViewCell 的 UIImageView 的大小

标签 iphone objective-c ios ipad

现在我知道 UITableViewCell 默认有一个 imageView 但是我尝试调整它的大小和原点,但它不会这样做。我是否必须为此创建 UITableViewCell 的子类?

最佳答案

如果你想改变表格 View 单元格的默认样式,你最好继承一个,你可以通过 layoutSubviews 方法很容易地改变它的 ImageView 的框架,就像这样:

@implementation CustomTableViewCell

//...

- (void)layoutSubviews {
  [super layoutSubviews];

  // ...
  CGRect imageViewFrame = CGRectMake(...);
  [self.imageView setFrame:imageViewFrame];

  // you can also modify the frame or position for textLabel, detailTextLabel, etc.
}

@end

关于iphone - 是否可以重新定位和调整标准 UITableViewCell 的 UIImageView 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10747797/

相关文章:

iphone - 如何通过点击更改 UILabel 的 alpha?

iphone - UISearchDisplayController "shouldReloadTableForSearchString return NO"重新加载表

ios - iOS 应用程序中错误的聚光灯图标

iOS 8 : Where can I find a complete change log of iOS 8 compared with iOS 7?

ios - PFObject 中的 NSArray 值

iphone - 使用 initWithImage :(UIImage *)image 将图像添加到 UIBarButtonItem

objective-c - 使用 API 的 v3 在 Objective-C 中检索 YouTube channel 上传

ios - SpriteKit - 返回到与离开时相同的持久场景。

objective-c - "property with ' weak' attribute must be of object type"是什么意思?

ios - Objective-C - 如何单独解析我的 XML 的属性?