0

每当我缩放视图时,我的滚动视图都会出现问题。当我缩放视图时,它会自动定位在左上角。我想要做的是一旦移动它就保持在它所在的位置的视图。

这是我的代码:

    mainSV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
    [mainSV setPagingEnabled:YES];
    [mainSV setDelegate:self];
    [mainSV setShowsVerticalScrollIndicator:NO];
    [mainSV setShowsHorizontalScrollIndicator:NO];
    [mainSV setScrollEnabled:YES];
    [mainSV setUserInteractionEnabled:YES];
    [mainSV setMaximumZoomScale:2.0];
    [mainSV setMinimumZoomScale:1.0];
    [mainSV setMultipleTouchEnabled:YES];
    [mainSV setClipsToBounds:YES];
    [mainSV setContentSize:CGSizeMake(768, 1024)];
    [self.view addSubview:mainSV];

    innerSV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
    [innerSV setPagingEnabled:YES];
    [innerSV setDelegate:self];
    [innerSV setShowsVerticalScrollIndicator:NO];
    [innerSV setShowsHorizontalScrollIndicator:NO];
    [innerSV setScrollEnabled:YES];
    [innerSV setUserInteractionEnabled:YES];
    [innerSV setClipsToBounds:YES];
    [innerSV setContentSize:CGSizeMake(768*numOfPages, 1024)];
    [mainSV addSubview:innerSV];

- (UIView*)viewForZoomingInScrollView:(UIScrollView *)aScrollView {

    return innerSV;
}

InnerSV 也是一个UIScrollView包含我的应用程序中所有图像的。

4

1 回答 1

1

问题是由innerSV滚动视图分页造成的。将其设置为 FALSE,它应该可以工作。

干杯!

于 2012-10-12T06:53:06.827 回答