Ios 滚动视图在点击时向上移动

Ios 滚动视图在点击时向上移动,ios,iphone,imageview,scrollview,Ios,Iphone,Imageview,Scrollview,我是iPhone开发新手。我在UIScrollView(zoomscrollView)中包含的UIImageView中有一个图像,它包含在另一个UIScrollView(scrollViewgalery)中 我的问题是,当触摸第一个滚动视图(即zoomScrollview)时,它会向上移动。我使用了以下代码:-(无效)ScrollViewWillBeginDelegrating:(UIScrollView*)scrollview{[scrollview设置内容偏移:scrollview.cont

我是iPhone开发新手。我在UIScrollView(zoomscrollView)中包含的UIImageView中有一个图像,它包含在另一个UIScrollView(scrollViewgalery)中


我的问题是,当触摸第一个滚动视图(即zoomScrollview)时,它会向上移动。

我使用了以下代码:-(无效)ScrollViewWillBeginDelegrating:(UIScrollView*)scrollview{[scrollview设置内容偏移:scrollview.contentOffset动画:YES];},这帮助我停止了UIScrollView的垂直移动。但现在我在水平滚动方面遇到了问题,也就是说,在分页方面我遇到了问题。分页不太顺畅。
I Hope you need a view similar to photos gallery view. Here u will need a main scrollviewGallery and inside it your scrollviewZoom whose height should be same as scrollViewGallery for horizontal scroll and scrollViewZooms width should be same as scrollViewGallery for vertical scroll. Also Make sure u have enabled pagination for scrollViewGallery.


Your sample code goes here
                [_scrollView setDelegate:self];
    int index=0;
        for (NSString* stringImageName in self.arrayGalleryImages)
        {
    UIScrollView *imgScroll=[[UIScrollView alloc]initWithFrame:CGRectMake(index*CGRectGetWidth(_scrollView.frame),0,CGRectGetWidth(_scrollView.frame),CGRectGetHeight(_scrollView.frame))];
                [imgScroll setDelegate:self];
                [imgScroll setTag:index];
                [imgScroll setScrollEnabled:NO];
                [imgScroll setMinimumZoomScale:1.0];
                [imgScroll setMaximumZoomScale:3.0];
                [imgScroll setAutoresizingMask:UIViewAutoresizingFlexibleHeight];

                UIButton *btnGallery=[[UIButton alloc] initWithFrame: imgScroll.bounds];
                [btnGallery addTarget:self action:@selector(gotoFullScreenGallery) forControlEvents:UIControlEventTouchUpInside];
                [btnGallery setAdjustsImageWhenHighlighted:NO];
                [btnGallery setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
                [btnGallery setTag:index];
                [[btnGallery imageView] setContentMode: UIViewContentModeScaleAspectFit];
    [btnGallery setImage:[UIImage imageNamed:stringImageName] forState:UIControlStateNormal];
     [imgScroll addSubview:btnGallery];
                [_scrollView addSubview:imgScroll];
            index++;
        }
        [_scrollView setContentSize:CGSizeMake(index*CGRectGetWidth(_scrollView.frame), CGRectGetHeight(_scrollView.frame))];

Assuming arrayGalleryImages consists of gallery image names.
I used button to add more action on tap.


Try code and manage scrollview delegate methods

    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
    {
        if([previouslyZoomedScroll zoomScale]!=1.0)
        {
            [previouslyZoomedScroll setZoomScale:1.0];
        }
    }