How can I zoom in and out in a UIImageView without UIScrollView?

Ok. You can consider using a UIScrollView if only to use it for its zoom functionality.

Ok. You can consider using a UIScrollView if only to use it for its zoom functionality. Say we have a scrollView and a imageView with both having the same bounds.

Add the imageView as the subview of scrollView. ScrollView addSubview:imageView; scrollView. ContentSize = imageView.frame.

Size; To support only zoom and not not panning in the scrollView your viewController will have to adopt the UIScrollViewDelegate protocol. // Disabling panning/scrolling in the scrollView scrollView. ScrollEnabled = NO; // For supporting zoom, scrollView.

MinimumZoomScale = 0.5; scrollView. MaximumZoomScale = 2.0; ... // Implement a single scroll view delegate method - (UIView*)viewForZoomingInScrollView:(UIScrollView *)aScrollView { return imageView; } By now we have zooming available. For swipes, you can use appropriately configured UISwipeGestureRecognizers.

Create a gesture for handling each swipe direction and add it to scroll view. UISwipeGestureRecognizer *rightSwipe = UISwipeGestureRecognizer alloc initWithTarget:self selector:@selector(handleRightSwipe:); rightSwipe. Direction = UISwipeGestureRecognizerDirectionRight; rightSwipe.

NumberOfTouchesRequired = 1; scrollView addGesture:rightSwipe; rightSwipe release; And retrieve the appropriate image based on the gesture and set it using imageView. Image = yourImage;.

Thanks for your reply! I ll try it! – Orus May 19 at 8:30 Ok, that works, but I want to use swipe like touchesMoved, because I need to change the Image when I m moving the finger.

This works with 1 move, 1 image change. – Orus May 19 at 8:41 Hmm.. I can suggest you to replace Swipe with Pan gesture recognizers. Configure the selector triggered by the pan gesture recognizer to behave like your touches moved method as it does contain the translation data for you to work with.

But this would require each image view to be contained within a scrollView. – Deepak May 19 at 9:42 Alternately, you can look at the transform property in UIImageView. – Deepak May 19 at 9:43 Thank you!

I'll take a look to both and I'll post my solution. – Orus May 19 at 10:06.

Finally, with Deepak's help, I use the transform property of UIImageView to make the Zooming. I use the CGFloat at the position 0,0 in the matrix of the CGAffineTransform to set the limits. I have to pass the CGFloat to a string at zoom in because when I compare him with 0 this is always true.

Finally this is my code in touchesMoved, if it's useful for somebody: // comparo para saber si el usuario esta haciendo zoom in o zoom out if(initialDistance F, C: %. F, D: %. F", imagen.transform.

A, imagen.transform. B, imagen.transform. C, imagen.transform.

D); if (transformer. A Transform, 0.95, 0.95); NSLog(@"transformer :: A: %. F, B: %.

F, C: %. F, D: %. F", transformer.

A, transformer. B, transformer. C, transformer.

D); NSString *num = NSString stringWithFormat:@"%. F", transformer. A; if (!num isEqualToString:@"0") { UIView beginAnimations:nil context:NULL; UIView setAnimationDuration: 0.2; imagen.

Transform = transformer; UIView setAnimationDelegate:self; UIView commitAnimations; } } And of course, a lot of thanks to Deepak. Sorry but I cant vote you now, I havent enought reputation.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions