Reputation: 3517
AspectFill
doesn't work so well with ScrollView
.
This is my code
-(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];
}
Upvotes: 1
Views: 613
Reputation: 3286
I believe your scroll view has autoresizesSubviews
enabled, disable it and your images will appear (and the default view mode for images should be just fine)
Upvotes: 0
Reputation: 7388
Add this:
[scrollView setContentMode:UIViewContentModeScaleAspectFit];
[imageView sizeToFit];
Should work :-)
Upvotes: 2