Iphone 嵌套的滚动视图显示不正确

Iphone 嵌套的滚动视图显示不正确,iphone,ios,uiview,uiscrollview,addsubview,Iphone,Ios,Uiview,Uiscrollview,Addsubview,我在尝试实现一对嵌套的滚动视图时遇到了一个小问题。 我已经设法实现了它们,但是我的图像似乎没有正确显示。它们各自都很好,但随着滚动视图的嵌套,帧似乎会改变大小和位置 下面是我的一些代码,可能用来说明我做错了什么 - (void)loadView {{ CGRect baseScrollViewFrame = [self frameForBaseScrollView]; baseScrollView = [[UIScrollView alloc] initWithFrame:baseScrol

我在尝试实现一对嵌套的滚动视图时遇到了一个小问题。 我已经设法实现了它们,但是我的图像似乎没有正确显示。它们各自都很好,但随着滚动视图的嵌套,帧似乎会改变大小和位置

下面是我的一些代码,可能用来说明我做错了什么

- (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];
这是用于分页垂直滚动视图

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

- (void)loadView 

多谢了,也许可以看看您正在实现的委托方法。您正在将两个scrollview的委托都设置为“self”。在这些方法中,您是否正在检查哪个scrollview调用了它


根据imageCount设置高度和宽度似乎也有点奇怪。例如,如果图像计数为10,则会有100页(10页宽x 10页高).

为什么要使用嵌套滚动视图?单个滚动视图可以有水平和垂直滚动。是否要将每个行滚动和组合滚动分开?