UiScrollview滚动分页

时间:2012-05-14 17:21:36

标签: objective-c ios5

我已经实现了一个UIScrollView。它包含60个宽度的小图像。 滚动运动总是前进或后退三张图片,而不是我需要的一张一张。请参阅附带的图片来解释这一点。

enter image description here

ScrollView启用了分页功能。这是代码:

for (int i = 0; i < numberOfViews; i++) {

        UIImage *myImage = [UIImage imageNamed:[fotosJugadores objectAtIndex:i]];
        CGFloat yOrigin = i * myImage.size.width + 120;
        UIImageView *awesomeView = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, myImage.size.width, myImage.size.height)];
        awesomeView.image = myImage;
        awesomeView.tag = i;
        [self.jugadorSlide addSubview:awesomeView];
        awesomeView=nil;
    }

    [jugadorSlide setBackgroundColor:[UIColor blackColor]];
    jugadorSlide.contentSize = CGSizeMake(65 * numberOfViews+240,78);
    jugadorSlide.layer.cornerRadius = 11;
    jugadorSlide.layer.masksToBounds = YES;
    [jugadorSlide setContentOffset:CGPointMake(((65 * numberOfViews)/2), 0)];
    [self scrollViewDidEndDecelerating:jugadorSlide];

非常感谢

1 个答案:

答案 0 :(得分:2)