Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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
自定义UITableViewCell-将图像设置为单元格高度_Uitableview - Fatal编程技术网

自定义UITableViewCell-将图像设置为单元格高度

自定义UITableViewCell-将图像设置为单元格高度,uitableview,Uitableview,我在自定义UITableViewCell内创建UIImageView。我想将UImageView的高度设置为与单元格的高度相匹配,但无法正确设置。我不想硬编码一个值。我试过了 self.imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 70, self.frame.size.height)]; 及 我以为这会将图像设置为单元格的高度,但它的高度不同 “我的单元格高度”是80的自定义高度。首先,“imageView”是UI

我在自定义UITableViewCell内创建UIImageView。我想将UImageView的高度设置为与单元格的高度相匹配,但无法正确设置。我不想硬编码一个值。我试过了

self.imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 70, self.frame.size.height)];

我以为这会将图像设置为单元格的高度,但它的高度不同

“我的单元格高度”是80的自定义高度。

首先,“imageView”是UITableViewCell的保留属性。如果要添加自己的UIImageView,则不能使用它

我想您的项目中没有使用自动布局。所以,只需将自动调整大小的遮罩添加到图像视图中即可

self.yourImageView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 70, self.contentView.bounds.size.height)];
self.yourImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

是的,这起作用了。你是对的,imageView是一个保留字,我只是在示例中使用它。谢谢你的帮助。
self.yourImageView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 70, self.contentView.bounds.size.height)];
self.yourImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight;