how can i use UISCrollView paging with different heights?
I have a UIScrollView which shows multiple images when user swipe horizon开发者_如何学Ctally. But these images does not have the same height. The first image has height taller then the second.
1.What I want to do is when the person swipes, the next picture shown, is positioned at the top.
2.Also when using ScrollView's paging, the vertical scrolling is not smooth, it skips a whole frame. I've read that i cannot use ScrollView's paging to get the vertical scrolling smooth.
Any ideas?
For the 1st problem should I load nibs with images inside? How do I load a nib after swiping?
updated question:is there a way, i can load nibs(with its own scroll and imageview inside) as i swipe from left to right or right to left? because loading images side by side in the uiscrollview isn't going to do the trick.
set
[imageView setContentMode:UIViewContentModeScaleAspectFit];
this will show the image in proper aspect ... you don't have to worry about image size
[imageView setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin];
this will keep your imageView attached to the top of scrollView.
If you want every image to show at the top of the scrollView adjust the image.frame accordingly.
UIImageView *imageView;
UIImage *image = [UIImage imageWithData:loadTheImage];
imageView.image = image;
imageView.frame = CGRectMake(0, 0, 280, 480);
In the CGRectMake the first two values specify the padding for the image. The first is x value, the second y value. If both are 0, the image is displayed in the top left. Does this make sense?
精彩评论