I have an image like:
When I load the image to uiimageview and then adding as a subview to uiscrollview, at start the image is showing like:
The problem is I want to see all the image fit to screen at start but it is showing already zoomed. Is there a way to handle this please help ...
I have the code like:
[self.view addSubview:scrollView];
UIImageView *tempImageView =
[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Tree.jpg"]];
self.imageView = tempImageView;
[tempImageView release];
[scrollView setContentMode:UIViewContentModeScaleAspectFit];
[imageView sizeToFit];
scrollView.backgroundColor=[UIColor blackColor];
scrollView.contentSize = imageView.frame.size;
scrollView.minimumZoomScale = scrollView.frame.size.width / imageView.frame.size.width;
scrollView.maximumZoomScale = 4.0;
[scrollView setZoomScale:1.0];
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
[scrollView addSubview:imageView];
Probably you are looking for this,
UIImageView *tempImageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Watson.jpg"]] autorelease];
tempImageView.frame = scrollView.bounds;
self.imageView = tempImageView;
scrollView.backgroundColor = [UIColor blackColor];
scrollView.minimumZoomScale = 1.0 ;
scrollView.maximumZoomScale = imageView.image.size.width / scrollView.frame.size.width;
scrollView.zoomScale = 1.0;
scrollView.delegate = self;
[scrollView addSubview:imageView];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With