xcode - zooming in and out of a UIView -


what best way zoom in , out of uiview simple method buttons. (e.i

(ibaction)zoomin:(int)distance { method here } (ibaction)zoomout:(int)distance { , here } 

it can done using 2 finger gesture recognizer: have write down:-

-(void)viewdidload { uipinchgesturerecognizer *twofingerpinch = [[[uipinchgesturerecognizer alloc]                                             initwithtarget:self                                             action:@selector(twofingerpinch:)]                                             autorelease];  [[self view] addgesturerecognizer:twofingerpinch]; } 

by have initialized instance take care of 2 finger sensations on screen (or view on applying method) define if have recognized 2 fingers:

- (void)twofingerpinch:(uipinchgesturerecognizer *)recognizer  {     nslog(@"pinch scale: %f", recognizer.scale);     cgaffinetransform transform = cgaffinetransformmakescale(recognizer.scale, recognizer.scale);                                       // can implement int/float value in context of scale want zoom in or out     self.view.transform = transform; } 

the above defined method called automatically not through uibutton actions solve problem simplicity if strictly want use zoom @ ibaction this:

 -(ibaction)methodcalledonclickinguibutton:(id)sender {     if(sender==zoominbutton)      {        scalevalue++;      }     else if(sender==zoomoutbutton)      {        scalevalue--;      }      cgaffinetransform transform = cgaffinetransformmakescale(scalevalue,scalevalue);      self.view.transform = transform; } 

where scalevalue float value..you can set according application requirement! hope work fine you! :)


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -