How can I zoom an image inside a scroll view using objective c methods? Page control is also used here for paging the scroll view.

I have a pagecontrol using which I am managing a scroll view. Different pages in the scroll view contains imageviews. I want to zoom the images in that. Please help to find a solution. Following is my code.

              pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, self.navigationController.navigationBar.frame.size.height, self.view.bounds.size.width,self.view.bounds.size.height/3)];
                [self.view addSubview:pageControl];
                scrollView =[[UIScrollView alloc] initWithFrame:CGRectMake(0, self.navigationController.navigationBar.frame.size.height, self.view.bounds.size.width,self.view.bounds.size.height/3)];
                scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * floorIdArray.count, scrollView.frame.size.height);
                for( int i=0;i<floorIdArray.count; i++) {
                    NSString *floorid = [[NSString alloc] initWithFormat:@"%@",[floorIdArray objectAtIndex:i]];
                    NSString *imagePath = @"http:/
                    imagePath = [imagePath stringByAppendingString:floorid];
                    CGRect frame;
                    frame.origin.x = scrollView.frame.size.width * i;
                    frame.origin.y = 0;
                    frame.size = scrollView.frame.size;
                    UIImageView* imgView = [[UIImageView alloc] init];
                    [imgView sd_setImageWithURL:[NSURL URLWithString:imagePath]
                                            placeholderImage:[UIImage imageNamed:@"imgmap.png"]];
                    imgView.frame = frame;
                    [scrollView addSubview:imgView];
                    UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchDetected:)];
                    pinchRecognizer.delegate=self;
                    [scrollView addGestureRecognizer:pinchRecognizer];
                }
                pageControl.currentPage = 0;
                pageControl.numberOfPages = floorIdArray.count;
             
              
                [self.view addSubview:scrollView];

These days I have had better luck letting the scroll view determine its content size using auto layout. I make constraints from my scroll view's content view (I always place all my content inside a single UIView that is the only subview of the scroll view) to the scroll view, and also from the subviews of my content view to the content view. Then the intrinsic size or width/height constraints on the subviews determine the content size.


I admit I haven't tried using a page control though so YMMV.

How can I zoom an image inside a scroll view using objective c methods? Page control is also used here for paging the scroll view.
 
 
Q