UIScrollView 的缩放功能有问题。它根本不起作用。我读过类似的帖子,其他人使用的修复似乎都不适合我。我的 viewController 引用了 UIScrollViewDelegate,我有一个 UIScrollView 的实例变量,我将我的子视图声明为 UIScrollView 的委托对象,并且我有(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
. 这是我的 loadView 函数:
(void)loadView
{
CGRect frame = CGRectMake(0, 0, 320, 480);
scrollView = [[UIScrollView alloc] initWithFrame:frame];
[scrollView setScrollEnabled:YES];
CGRect reallyBigRect;
reallyBigRect.origin = CGPointZero;
reallyBigRect.size.width = frame.size.width * 2.0;
reallyBigRect.size.height = frame.size.height * 2.0;
[scrollView setContentSize:reallyBigRect.size];
CGPoint offset;
offset.x = frame.size.width * 0.5;
offset.y = frame.size.height * 0.5;
[scrollView setContentOffset:offset];
[scrollView setMinimumZoomScale:1];
[scrollView setMaximumZoomScale:5];
[scrollView setUserInteractionEnabled:YES];
self.scrollView.delegate = self;
self.view = scrollView;
views = [[HypnosisView alloc] initWithFrame:reallyBigRect];
[scrollView addSubview:views];
[self.view setBackgroundColor:[UIColor clearColor]];
}
此代码允许我很好地滚动,但不存在缩放。
希望收到某人的来信,戴夫