views:

27

answers:

2
+1  A: 

-[UIImageView initWithImage:] sets the frame to be the image's size. You'll need to use page.frame = [[UIScreen mainScreen] bounds] or similar to scale images to the correct size.

tc.
Thank you I did try that but not in conjunction with the AspectFit and it works :D. Just need to figure out how to set the imageViews in the main scrollView.
SamRowley
+1  A: 

If you're using UIImageViews, you should make sure that your view has its clipsToBounds field set to yes. Try adding:

UIImageView *page = [[UIImageView alloc] 
                           initWithImage:[imgArray objectAtIndex:i]];
[page setContentMode:UIViewContentModeScaleAspectFit];
[page setClipsToBounds:YES];
[pagingScrollView addSubview:page];

Then, make sure you are setting your image's frame to the correct offset within the scroll view. The frame's origin.x needs to be the width of the frame times the image index. So you need something like this:

[page setFrame:CGRectMake(i*pagingScrollViewFrame.size.width, y, width, height)];

where i is your index from your for loop.

Though in the sample code from the WWDC session you're referring to, this is done in a method called -configurePage. Have you downloaded the sample code?

Matt Long
Yeah I have the sample code and tried to figure out what was going on from that but I decided I would try and write is simply myself from the diagrams they showed at WWDC 2010 with the individual layers of the PhotoScroller, so Paging layer, Zooming layer then UIImage view as the subview, but then take it down a level again and just get the paging working first then build up from that. From your answer I can't set the clipsToBounds work saying page is not a struct or union.
SamRowley