Array of Images display in UIScrollview and Paging successfully but cannot properly zoom-in images in scrollview

前端 未结 2 1177
死守一世寂寞
死守一世寂寞 2021-02-11 08:33

I am working on UIScrollview with ImageArray. Scrolling and paging are working but I not able to zoom each image. My code of image Scrollview is below :-

#define I

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-11 09:21

    for ( NSString *image in photos )
        {
           UIImage *images = [photos objectAtIndex:i];
           imageView = [[UIImageView alloc] initWithImage:images];
           imageView.contentMode = UIViewContentModeScaleAspectFit;
           imageView.clipsToBounds = YES;
           imageView.tag = 1;
    
           UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake( IMAGE_WIDTH * i++, 0, IMAGE_WIDTH, IMAGE_HEIGHT)];
           scrollView.delegate = self;
           scrollView.maximumZoomScale = 3.0f
           imageView.frame = scrollView.bounds;
           [scrollView addSubview:imageView];
           [imageView release];
    
           [self.scrollViewimages addSubview:scrollView];
    
         }
    

    And Implement the delegate method in UIScrollViewDelegate

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

提交回复
热议问题