[英]image view frame in cell of a table view
我已將圖像添加到我的iOS應用程序的resources文件夾中。 我想將該圖像添加到UITableView
每個單元格中。 我像這樣調整cellForRowAtIndexPath
中圖像的大小:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
cell.imageView.frame=CGRectMake(10, 27, 30, 30);
}
但是我的圖像顯示的尺寸類似於資源文件圖像,但是我希望它在上述框架處顯示。
我的研究給了我這個主意:
-(void)layoutsubviews
{
cell.imageView.frame=CGRectMake(10, 27, 30, 30);
}
我該如何使用?
試試看
-(void)layoutsubviews
{
self.imageView.frame=CGRectMake(10, 27, 30, 30);
}
我不確定編譯器如何允許您訪問-layoutSubviews
方法中的cell
。 簡而言之,您在此處設置的任何框架都將覆蓋UITableViewCell的默認框架。
您是否嘗試過[cell.imageView setContentMode:UIViewContentModeAspectFit];
?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.