I have embedded an image view into a scroll view for zooming purposes. Everything works great but if the user choses to zoom in then pan in any direction the user can slightly pull the ScrollView off the screen bounds exposing the content i have behind the scrollview before bouncing back. I want to disable this bouncing when zoomed in but don't know how. This only happens when zoomed in. At normal zoom scale you can't do it. Heres my code I have gone through the UIScrollView Class Reference and have commented out my attempts at disabling it but it doesn't work!

    zoomScrollView.contentSize = CGSizeMake(enlargedPhotoImageView.frame.size.width , enlargedPhotoImageView.frame.size.height);
    zoomScrollView.maximumZoomScale = 10;
    zoomScrollView.minimumZoomScale = 1;
    zoomScrollView.clipsToBounds = YES;
    zoomScrollView.delegate = self;
    zoomScrollView.zoomScale = 1;
    //zoomScrollView.alwaysBounceHorizontal = NO;
    //zoomScrollView.alwaysBounceVertical = NO;
    //zoomScrollView.bouncesZoom = NO;

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{

    if(scrollView == zoomScrollView){
        return enlargedPhotoImageView;
    }else{
        return nil;
    }
}
有帮助吗?

解决方案

zoomScrollView.bounces = NO;

Will prevent overscroll. But...scrollviews that don't bounce usually feel very weird to users; bear in mind that there's probably a better way to accomplish whatever you're trying to do.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top