分页滚动视图垂直移动到

时间:2011-04-05 06:34:29

标签: objective-c cocoa-touch uiscrollview

我的分页滚动视图水平和垂直移动,它只能水平移动。我做了一个由2个视图组成的应用程序,分页滚动视图是其中一个框架为320 * 400的子视图。我的分页滚动视图是320 * 360 frame.i以为它只会水平移动。我粘贴了部分代码:

    CGRect pagingScrollViewFrame = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);
        pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
        pagingScrollView.pagingEnabled = YES;
        pagingScrollView.backgroundColor = [UIColor blackColor];
        pagingScrollView.showsVerticalScrollIndicator = NO;
        pagingScrollView.showsHorizontalScrollIndicator = NO;
        pagingScrollView.contentSize = [self contentSizeForPagingScrollView];
        pagingScrollView.delegate = self;
        self.view = pagingScrollView;
...
    - (CGSize)contentSizeForPagingScrollView {
        CGRect bounds = pagingScrollView.bounds;
        return CGSizeMake(bounds.size.width * [self imageCount], bounds.size.height);
    }
...
    - (NSUInteger)imageCount {
        static NSUInteger __count = NSNotFound;  
        if (__count == NSNotFound) {
            __count = ([rootArray count]/5);
        }

        return __count;
    }

感谢

1 个答案:

答案 0 :(得分:1)

尝试添加

pagingScrollViewFrame.scrollsToTop=NO;

希望它会有所帮助