0

I have searched a lot but not able to find anything fruitful.Here is my scenario:

I am making a horizontal Image Slider(UIScrollView) which consist of multiple images. The slider is working fine. But the problem arises when I implement Pinch-In Zoom-In-Out`.

I am using this delegate method to zoom a particular Image:

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
   return imgView;
}

Whenever I zoom-In any image the Image next to it changes its position and the image which I am zooming after I leave my finger the image slighly shift to left and top . It not stoping where I want to stop.

What I have Done: Programatically created image and added them to scrollView.

xPointer = 0;  
for(i=0;i<[imgArr count];i++)
   {
    UIImageView *imgToZoom= [[UIImageView alloc]init];
    imgToZoom.image = [imgArr objectAtIndex:i];
    imgToZoom.tag = i+100;
    imgToZoom.frame = CGRectMake(xPointer, _imagesScrollView.frame.origin.y-10, self.view.frame.size.width,_imagesScrollView.frame.size.height/2);
    [imgToZoom setUserInteractionEnabled:YES];
    [imgToZoom setMultipleTouchEnabled:YES];

    [_imagesScrollView addSubview:imgToZoom];

    xPointer = xPointer+self.view.frame.size.width;



}

_imagesScrollView.contentSize = CGSizeMake(xPointer, _imagesScrollView.frame.size.height);

How can I implement Pinch In zoom. As When I done it using apple Doc My other images are changing there position.And Zoom in also not to the point.

NSUser
  • 1,233
  • 9
  • 15
  • Seems a constraint problem, by Image Slider you probably mean UIScrollView.. how are the constraints between these images? – Roberto Ferraz Sep 24 '15 at 07:56
  • Yes you are right..I have placed images in ScrollView... – NSUser Sep 24 '15 at 08:20
  • @RobertoFerraz I have updated my question – NSUser Sep 24 '15 at 08:24
  • you don't have constraints, so it is hard to preview the behaviour that this will have. Try to use auto-layout and take a look in this answer (http://stackoverflow.com/questions/14471298/zooming-uiimageview-inside-uiscrollview-with-autolayout) – Roberto Ferraz Sep 24 '15 at 10:38

0 Answers0