iphone - Multi touch is not working perfectly on UIImageView -


I'm touching UIMage like zoom in and zoom out on image view. I'm using the followng code, but it does not work very well. Anyone can see this code,

#import "zoomingEZHHHHH" @implementation zoomingEzeg View @ synthesis zoomed out; @ Synthesis moved; Defined HORIZ_SWIPE_DRAG_MIN 24 defined VERT_SWIPE_DRAG_MAX 24 defined TAP_MIN_DRAG 10 CGPoint startTouchPosition; CGFloat initial error; - (id) initWithFrame: (CGRect) frame {if (self = [super initWithFrame: frame]) // // start code moved = no; Zoomed = No; } Healthy return; } - (zero) direct: (CGRact) rect {// drawing code} - (empty) Delok {if ([Timer is Valid]) [Invalid timer]; [Super DeLoc]; } - (Zero) Set Image: (UIImage *) img {zoomed = NO; Transferred = no; Self.transform = CFEfeinttransferTTT; [Super set image: img]; } - (CGFLOT) Two points between distance point: (CGPEINT) to point-to-point: (CP point) points {float x = two point.x - POP.x; Float y = toPoint.y - from Point.y; Return sqrt (x * x + y * y); } - (CGFloat) scale amounts: (CGFloat) delta {CGFloat pix = sqrt (self.frame.size.width * self.frame.size.height); CGFloat scale = 1.0+ (delta / pixel); Return scale; } - (zero) touches: (NSSET *) touches the event: (UIEVENT *) event {if ([timer is wild]) [invalid timer]; Transferred = no; Switch ([counting]] {case 1: {// single touch uit touch * touch = [touches an object]; StartTouchPosition = [Touch Location InViv: Self]; Initial error = -1; break; } Default: {// multi-touch uit touch * touch1 = [[touches all the object] ObjectOtInx: 0]; UITT * touch2 = [[touches the object] ObjectItendex: 1]; InitialDistance = [self distance between two points: [touch1 location: view: self] sepointe: [touch2 location: view: self]]; break; }}} - Enhanced the touch (void): (NSSET *) touches the event: (UIEVENT *) event {UITT * Touch1 = [[touches the object] ObjectAtindex: 0]; If ([timer is invalid]) [invalid timer]; / * If ([count touches] == 1) {CG point pause = [Touch 1 location invoice: self]; Self.transform = CGAffineTransformTranslate (self.transform, pos.x - startTouchPosition.x, pos.y - startTouchPosition.y); Moved = yes; Return; } **** / if ((initial diastas> 0) & amp; ([counting]> 1)) {UITouch * touch2 = [[touches all objects] ObjectItindex: 1]; CGFloat currentDistance = [Self Distance Payment Two points: [touch 1 spot invoice: self] to point: [Touch 2 place invoice: self]]; CGFloat movement = present-day - initial error; NSLog (@ "Touch Transfered:% F", Movement); CGFloat scale = [self scale scale: movement]; Self.transform = CGAffineTransformScale (self.transform, scale, scale); }}} - (zero) Touch-ended: (NSSET *) touches with the event: (UIEVENT *) event {UITT * Touch1 = [[touches the object] ObjectAtindex: 0]; If ([count touches] == 1) {// Double tap to reset to default size if ([Touch 1 tapacount]> 1) {if (zoomed) {self.transform = CGAffineTransformIdentity; Transferred = no; Zoomed = No; } Return; }} And {// multi-touch UITouch * touch2 = [[touches all objects] ObjectItindex: 1]; CGFloat finalDistance = [Self Distance: Between Two Points: [Touch 1 Location Inview: Self] Two Point: [Touch 2 Location Inview: Self]]; CGFloat movement = final position - initial error; NSLog (@ "Final distance:% F, movement =% F", final position, movement); If (movement! = 0) {CGFloat scale = [self scale volume: movement]; Self.transform = CGAffineTransformScale (self.transform, scale, scale); NSLog (@ "scaling:% F", scale); Zoomed = yes; }}} - (zero) singletap: (NSTimer *) will override theTimer {//} - (zero) Animus: must be overridden (int) {//}

It is not working properly on the device. Anyone can say that I am wrong.

When you use any CGAffinTransform ... the value of the frame becomes undefined In your code you are using frame.size.width and frame.size.height to calculate changes in size. You will not get the right scale factor after the first iteration of the Cagefin transcens scalales. According to the document boundary, the right asset for scale calculation will be.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -