- Joined
- Oct 11, 2011
- Messages
- 46
- Reaction score
- 0
- Points
- 6
- Your Mac's Specs
- 13" MacBook Pro 2.4 GHz 8 GB Ram 250 GB HD, iPhone 4/S 64 GB, iPhone 3GS 16 GB, iPad 16 GB Wi-Fi
i added zoom to pinch on the UIView in my iPhone app. but i can't limit how much it zooms in and out. i want the limit of zooming out to the size of the original view. and i want the zooming to be reasonable. can some one help me?
i added these two codes:
- (void)viewDidLoad
{
UIPinchGestureRecognizer *twoFingerPinch = [[[UIPinchGestureRecognizer alloc]
initWithTarget:self
actionselector(twoFingerPinch]
autorelease];
[[self view] addGestureRecognizer:twoFingerPinch];
}
&
- (void)twoFingerPinchUIPinchGestureRecognizer *)recognizer
{
NSLog(@"Pinch scale: %f", recognizer.scale);
CGAffineTransform transform = CGAffineTransformMakeScale(recognizer.scale, recognizer.scale);
// you can implement any int/float value in context of what scale you want to zoom in or out
self.view.transform = transform;
}
i added these two codes:
- (void)viewDidLoad
{
UIPinchGestureRecognizer *twoFingerPinch = [[[UIPinchGestureRecognizer alloc]
initWithTarget:self
actionselector(twoFingerPinch]
autorelease];
[[self view] addGestureRecognizer:twoFingerPinch];
}
&
- (void)twoFingerPinchUIPinchGestureRecognizer *)recognizer
{
NSLog(@"Pinch scale: %f", recognizer.scale);
CGAffineTransform transform = CGAffineTransformMakeScale(recognizer.scale, recognizer.scale);
// you can implement any int/float value in context of what scale you want to zoom in or out
self.view.transform = transform;
}