scrollviewdidendzooming没有被调用

时间:2014-01-07 17:57:13

标签: ios uiscrollview

我正在实现放大/缩小,我无法理解为什么scrollviewdidendzooming委托函数没有被调用。

这是我的代码。我很困惑viewForZoomingInScrollView函数被调用但scrollviewdidendzooming没有。

- (void)viewDidLoad {
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];
    _contentProgramsView = [[UIView alloc]initWithFrame:CGRectZero];
    _contentProgramsView.tag = 9999;
    [_contentProgramsView setUserInteractionEnabled:YES];
    _scrollView.contentSize = CGSizeMake(5*9*self.view.frame.size.width,self.view.frame.size.height+400);
    _scrollView.maximumZoomScale = 1.0f;
    _scrollView.minimumZoomScale = 2.0f;
    _scrollView.clipsToBounds = YES;
    _scrollView setBouncesZoom:YES];
    _scrollView.scrollEnabled = YES;
    _scrollView.scrollsToTop = NO;
    _scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    _scrollView.delegate = self;
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return [_scrollView viewWithTag:9999];
}

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale {
    //set the scrolling bounds
}

由于

1 个答案:

答案 0 :(得分:0)

_scrollView.maximumZoomScale = 1.0f;
_scrollView.minimumZoomScale = 2.0f;

maximumZoomScale需要大于minimumZoomScale。 解决这个问题应该可行,但如果没有,请添加_scrollView.multipleTouchEnabled = YES;

我希望这会有所帮助。