2012-10-12 48 views
0

我在缩放视图时遇到了滚动视图问题。 当我放大视图时,它会自动定位在左上角。我想要做的就是将视图保留在移动后的位置。Objective C:正确缩放UIScrollView

这里是我的代码:

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保存在我的应用程序的所有图像。

回答

1

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

干杯!

+0

FALSE对我来说 “否”发生了一些问题 非常感谢 –