1

AspectFill不能很好地与ScrollView.

这是我的代码

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    CGFloat pageWidth = self.scrollView.bounds.size.width;
    int page = floor((self.scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
    self.pageCount= page;
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.scrollView.frame.size.width * self.pageCount, 0, self.scrollView.frame.size.width, self.scrollView.frame.size.height)];
    [imageView setImageWithURL:[self.urlArray objectAtIndex:self.pageCount] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    [imageView setContentMode:UIViewContentModeRedraw];
    [self.scrollView addSubview:imageView];

}
4

3 回答 3

2

添加这个:

[scrollView setContentMode:UIViewContentModeScaleAspectFit];
[imageView sizeToFit];

应该管用 :-)

于 2013-03-06T07:49:56.043 回答
0

设置scrollview contentmode aspectfill

于 2013-03-06T08:12:03.997 回答
0

我相信您的滚动视图已autoresizesSubviews启用,禁用它并且您的图像将出现(并且图像的默认视图模式应该很好)

于 2013-03-06T08:09:34.513 回答