2012-10-12 95 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對我來說 「否」發生了一些問題 非常感謝 –