0

我在尝试实现一对嵌套滚动视图时遇到了一个小问题。我已经设法实现了它们,但是我所拥有的图像似乎没有正确显示。它们单独很好,但是嵌套的滚动视图似乎改变了框架的大小和位置。

这是我的一些代码,可以证明我做错了什么。

- (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];

这是用于分页垂直滚动视图。

请有人告诉我我做错了什么。

非常感谢

4

1 回答 1

0

也许看看您正在实现的委托方法。您正在将两个滚动视图的代表设置为“自我”。在这些方法中,您是否正在检查哪个滚动视图调用了它?

It also seems a bit odd that you are setting BOTH the height and width according to imageCount. If image count were 10 for example, you would have 100 pages (10 pages wide by 10 pages tall).

于 2011-04-18T16:58:51.240 回答