【发布时间】:2011-04-18 14:59:55
【问题描述】:
我在尝试实现一对嵌套滚动视图时遇到了一个小问题。 我已经设法实现了它们,但是我所拥有的图像似乎没有正确显示。它们单独很好,但是嵌套的滚动视图似乎改变了框架的大小和位置。
这是我的一些代码,可能证明我做错了什么。
- (void)loadView
{ {
CGRect baseScrollViewFrame = [self frameForBaseScrollView];
baseScrollView = [[UIScrollView alloc] initWithFrame:baseScrollViewFrame];
[baseScrollView setBackgroundColor:[UIColor blackColor]];
[baseScrollView setCanCancelContentTouches:NO];
baseScrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
baseScrollView.showsVerticalScrollIndicator = NO;
baseScrollView.showsHorizontalScrollIndicator = YES;
baseScrollView.scrollEnabled = YES;
baseScrollView.pagingEnabled = YES;
//baseScrollView.delaysContentTouches = NO;
baseScrollView.userInteractionEnabled = YES;
baseScrollView.contentSize = CGSizeMake(baseScrollViewFrame.size.width * [self imageCount], baseScrollViewFrame.size.height);
baseScrollView.delegate = self;
self.view = baseScrollView;
[baseScrollView release];
这是用于基本水平滚动视图
CGRect pagingScrollViewFrame = [self frameForPagingScrollView];
pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
pagingScrollView.pagingEnabled = YES;
pagingScrollView.backgroundColor = [UIColor blackColor];
[pagingScrollView setCanCancelContentTouches:NO];
pagingScrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
pagingScrollView.showsVerticalScrollIndicator = YES;
pagingScrollView.showsHorizontalScrollIndicator = NO;
pagingScrollView.scrollEnabled = YES;
pagingScrollView.contentSize = CGSizeMake(pagingScrollViewFrame.size.width, pagingScrollViewFrame.size.height * [self imageCount]);
pagingScrollView.delegate = self;
[baseScrollView addSubview:pagingScrollView];
这是用于分页垂直滚动视图。
请有人告诉我我做错了什么。
非常感谢
【问题讨论】:
-
为什么要使用嵌套滚动视图?单个 scrollView 可以有水平和垂直滚动。您是否尝试将每个行滚动和组合滚动分开?
标签: iphone ios uiview uiscrollview addsubview