每当我缩放视图时,我的滚动视图都会出现问题。当我缩放视图时,它会自动定位在左上角。我想要做的是一旦移动它就保持在它所在的位置的视图。
这是我的代码:
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
包含我的应用程序中所有图像的。