分页滚动视图垂直移动到

发布于 2024-10-30 11:16:03 字数 1117 浏览 1 评论 0原文

我的分页滚动视图正在水平和垂直移动,并且它应该仅水平移动。我制作了一个由 2 个视图组成的应用程序,分页滚动视图是其中一个视图的子视图,其帧为 320*400。我的分页滚动视图是 320*360 帧。我认为它只会水平移动。我粘贴了部分代码:

    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;
    }

谢谢

my paging scroll view is moving either horizontally and vertically and it should move only horizontally. I made an application which consists of 2 view the paging scroll view is a subview of one of them which frame is 320*400. my paging scroll view is 320*360 frame.i thought that it will move only horizontally. I pasted part of my code:

    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;
    }

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧夏天 2024-11-06 11:16:03

尝试添加

pagingScrollViewFrame.scrollsToTop=NO;

希望它会有所帮助

Try to add

pagingScrollViewFrame.scrollsToTop=NO;

Hope it will help

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文