Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.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
Iphone 在cell.background视图中拉伸图像_Iphone_Objective C_Ios_Uiimageview - Fatal编程技术网

Iphone 在cell.background视图中拉伸图像

Iphone 在cell.background视图中拉伸图像,iphone,objective-c,ios,uiimageview,Iphone,Objective C,Ios,Uiimageview,在横向模式下,我试图使单元格背景适当拉伸。我写了这段代码: UIImage* cellBackGroundImage = [UIImage imageNamed:@"button_listing_default.png"]; cellBackGroundImage = [cellBackGroundImage stretchableImageWithLeftCapWidth:290 topCapHeight:76]; deselectedBackground = [[UIImageView

在横向模式下,我试图使单元格背景适当拉伸。我写了这段代码:

UIImage* cellBackGroundImage = [UIImage imageNamed:@"button_listing_default.png"];

cellBackGroundImage = [cellBackGroundImage stretchableImageWithLeftCapWidth:290 topCapHeight:76];

deselectedBackground = [[UIImageView alloc] initWithImage:cellBackGroundImage] ;

[deselectedBackground setContentMode:UIViewContentModeScaleToFill]; 

cell.backgroundView = deselectedBackground;
图像大小为580x152。单元大小为280x76

但当我把我的设备变成横向时,图像的圆角会被缩放,但它们不应该被缩放

肖像外观:

景观外观:


图像本身:

您的cap值可能有误

cellBackGroundImage = [cellBackGroundImage stretchableImageWithLeftCapWidth:290 topCapHeight:76];
为什么它们这么大?你的圆角有这么大的半径吗?如果它们仅类似于10px,则使用
StretcableImagewithLeftCapWidth:10 topCapHeight:10
。这些值定义了图像的哪些部分不会被缩放


你能给我们看看你的照片吗?

我已经找到了造成我问题的原因。实际上是图像本身。当图像小于结果时,拉伸和自动调整大小可以正常工作,但如果图像应该更宽和更低(就像我的情况一样),则不能正常工作。
所以为了解决我的问题,我不得不使用更小的图像。

我尝试了cellBackGroundImage=[cellBackGroundImage stretchableImageWithLeftCapWidth:10 topCapHeight:10];但这没用所以我猜这些是你的视网膜图像?所以视网膜的边缘大约是30px。所以你的资本值应该是15分。(如果没有视网膜图像,则使用30点)。如果仍然不起作用,请向我们展示更多的代码。继续,接受一些问题的答案!给定代码中没有实际错误,请显示更多viewcontroller代码。比如
tableView:cellForRowAtIndexPath:
或者
应该旋转接口操作。。并告诉我们您的视图结构。如何在旋转时调整表的大小?你用的是自动调整标签,不是吗?