我在尝试实现一对嵌套滚动视图时遇到了一个小问题。我已经设法实现了它们,但是我所拥有的图像似乎没有正确显示。它们单独很好,但是嵌套的滚动视图似乎改变了框架的大小和位置。
这是我的一些代码,可以证明我做错了什么。
- (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];
这是用于分页垂直滚动视图。
请有人告诉我我做错了什么。
非常感谢