给循环效应来滚动查看[关闭](Give Circular Effect To Scroll View

2019-09-28 22:01发布

我有一个20倍阵列的图像。 添加包含滚动view.scroll垂直20图像即图像ImageView的。 现在我的要求就是给圆形效果滚动

对于实施例20 1 2 3 4后..同样图像显示。

我想,一个,但不适合我

- (void)scrollViewDidEndDecelerating:(UIScrollView *)sender
{
    NSLog(@"%f",scrollView.contentOffset.x);
    // The key is repositioning without animation
    if (scrollView.contentOffset.x == 0) {
        // user is scrolling to the left from image 1 to image 4
        // reposition offset to show image 4 that is on the right in the scroll view
    //  [scrollView scrollRectToVisible:CGRectMake(1280,0,320,416) animated:NO];

        [scrollView scrollRectToVisible:CGRectMake(6080, 0, 320, 416) animated:NO];

    }
    else if (scrollView.contentOffset.x == 6400) {
        // user is scrolling to the right from image 4 to image 1
        // reposition offset to show image 1 that is on the left in the scroll view


        [scrollView scrollRectToVisible:CGRectMake(0,0,320,416) animated:NO];

        //[scrollView scrollRectToVisible:CGRectMake(0, 0, 0, 0) animated:YES];
    }
}

帮我出这先谢谢了。

Answer 1:

Use Apple's Sample code for circular ScrollView http://developer.apple.com/library/ios/#samplecode/StreetScroller/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011102

Otherwise

Replace your code by the following

- (void)scrollViewDidEndDecelerating:(UIScrollView *)sender
{
    NSLog(@"%f",self.scrollView.contentOffset.x);
    // The key is repositioning without animation
    if (self.scrollView.contentOffset.x == 0) {
        // user is scrolling to the left from image 1 to image 4
        // reposition offset to show image 4 that is on the right in the scroll view
        //  [scrollView scrollRectToVisible:CGRectMake(1280,0,320,416) animated:NO];

//        [self.scrollView scrollRectToVisible:CGRectMake(6080, 0, 320, 416) animated:NO];
         [self.scrollView setContentOffset:CGPointMake(6080, 0) animated:YES];
    }
    else if (self.scrollView.contentOffset.x == 6080) {
        // user is scrolling to the right from image 4 to image 1
        // reposition offset to show image 1 that is on the left in the scroll view

        [self.scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
//        [self.scrollView scrollRectToVisible:CGRectMake(0,0,320,416) animated:NO];

        //[scrollView scrollRectToVisible:CGRectMake(0, 0, 0, 0) animated:YES];
    }
}

It might help you



文章来源: Give Circular Effect To Scroll View [closed]