每当我缩放 View 时,我的 ScrollView 都会出现问题。 当我缩放 View 时,它会自动定位在左上角。我想要做的是 View 在移动后保持在原来的位置。
这是我的代码:
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
,它包含我的应用程序中的所有图像。
最佳答案
问题是由 innerSV
ScrollView 分页造成的。
将其设置为 FALSE,它应该可以工作。
干杯!
关于objective-c - Objective-C : Zooming UIScrollView Properly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12853588/