Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 设置tableView单元格大小上的图像_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 设置tableView单元格大小上的图像

Ios 设置tableView单元格大小上的图像,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有tableView单元格大小,需要在tableView单元格上设置image,但image未设置定义单元格大小(以下代码进入tableView存储的单元格大小cellSize变量)。 我的密码是 CGRect cellSize = [tableView rectForRowAtIndexPath:indexPath]; cell.imageView.frame = cellSize; cell.imageView

我有
tableView
单元格大小,需要在
tableView单元格上设置image
,但image未设置定义单元格大小(以下代码进入
tableView
存储的单元格大小
cellSize
变量)。 我的密码是

CGRect cellSize = [tableView rectForRowAtIndexPath:indexPath];
                    cell.imageView.frame = cellSize;
                    cell.imageView.image = [UIImage imageNamed:@"logo_black.png"];
图像中的上述代码未在
表格视图单元格中正确设置图像


那么,如何在
表格视图
单元格
上设置图像?

如果您试图说您在每个单元格中设置的图像没有显示在正确的位置,那么您可以尝试执行以下操作:

首先创建一个原型单元,并将
UIImageView
定位在单元u所需的正确位置,然后转到
UIImage
的比例属性并记下坐标。。。然后

而不是

CGRect cellSize = [tableView rectForRowAtIndexPath:indexPath];
                    cell.imageView.frame = cellSize;
这样,您可以按如下方式编写代码:

cell.imageView.frame = CGRectMake(x,y,width,height);


如果您试图说您在每个单元格中设置的图像未显示在正确的位置,则您可以尝试执行以下操作:

首先创建一个原型单元,并将
UIImageView
定位在单元u所需的正确位置,然后转到
UIImage
的比例属性并记下坐标。。。然后

而不是

CGRect cellSize = [tableView rectForRowAtIndexPath:indexPath];
                    cell.imageView.frame = cellSize;
这样,您可以按如下方式编写代码:

cell.imageView.frame = CGRectMake(x,y,width,height);

请尝试以下代码:

UIView *bgView = [[UIView allow ] init];
bgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageName:@"imgName"]];
cell.selectedBackgroundView = bgView;
请尝试以下代码:

UIView *bgView = [[UIView allow ] init];
bgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageName:@"imgName"]];
cell.selectedBackgroundView = bgView;

你说设置不正确是什么意思。?请详细说明接受答案有什么错?既然你已经接受了它???你是想设置一个图像作为背景吗?你说设置不正确是什么意思。?请详细说明接受答案有什么错?既然你已经接受了它???你正在尝试设置一个图像作为背景吗?