Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.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:UIViewContentModeScaleSpectFill未应用于某些图像(不工作)_Ios - Fatal编程技术网

iOS:UIViewContentModeScaleSpectFill未应用于某些图像(不工作)

iOS:UIViewContentModeScaleSpectFill未应用于某些图像(不工作),ios,Ios,我看到一些奇怪的行为,UIViewContentModeScaleSpectFill contentMode在某些图像上设置正确,但在其他图像上设置不正确。以下是我设置图像的方式: self.photos = @[ [UIImage imageNamed:@“pic1.jpg"], [UIImage imageNamed:@“pic2.jpg"]]; for (int i = 0; i < self.photos.count; i++) { UIImageView

我看到一些奇怪的行为,UIViewContentModeScaleSpectFill contentMode在某些图像上设置正确,但在其他图像上设置不正确。以下是我设置图像的方式:

  self.photos = @[ [UIImage imageNamed:@“pic1.jpg"],  [UIImage imageNamed:@“pic2.jpg"]];

  for (int i = 0; i < self.photos.count; i++)
  {
    UIImageView *picView = [UIImageView new];
    picView.image = self.photos[i];
    picView.frame = Frame(1080.0 * i,0,1080.0,self.picHeight);
    picView.contentMode = UIViewContentModeScaleAspectFill;
    picView.clipsToBounds = YES;
    [self.photoScrollView addSubview:picView];
  }
self.photos=@[[UIImage ImageName:@“pic1.jpg”],[UIImage ImageName:@“pic2.jpg”];
对于(int i=0;i
这是pic1.jpg,其中UIViewContentModeScaleAspectFill不受尊重,pic垂直挤压: ic2.jpg

这是pic2.jpg,UIViewContentModeScaleAspectFill在其中执行它应该执行的操作。两个图像的代码相同。

这感觉真的像是苹果端的一个bug,但我确实找到了一个非常简单的解决方法

将UIImageView添加到其superview后,我只需执行以下操作,即可使UIViewContentModeScaleAspectFill正常工作:

picView.frame = CGRectMake(picView.frame.origin.x, picView.frame.origin.y, picView.frame.size.width, picView.frame.size.height + 1);

这真的感觉像是苹果端的一个bug,但我确实找到了一个非常简单的解决方法

将UIImageView添加到其superview后,我只需执行以下操作,即可使UIViewContentModeScaleAspectFill正常工作:

picView.frame = CGRectMake(picView.frame.origin.x, picView.frame.origin.y, picView.frame.size.width, picView.frame.size.height + 1);