title: Switch image to full screen on ipad
body: <p>I have a lot of trouble to accomplish this task on an ipad : when double tape on an image switch this image to full screen and when double taping again come back to the original display, same thing using pinching. I'm using <code>UIGestureRecognizer</code> to try to do this. Thanks for your help.</p>
  
  <blockquote>
  <pre><code>GesturesViewController.h
  </code></pre>
  </blockquote>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface GesturesViewController : UIViewController 
      &lt;UIActionSheetDelegate&gt;{
      IBOutlet UIImageView *imageView;
  }
  
  @property (nonatomic, retain) UIImageView *imageView;
  
  @end
  </code></pre>
  
  <blockquote>
  <pre><code>GesturesViewController.m
  </code></pre>
  </blockquote>
  
  <pre><code>    #import "GesturesViewController.h"
  #import "GesturesAppDelegate.h"
  
  @implementation GesturesViewController
  
  @synthesize imageView;
  
  
  CGRect originalFrame,fullScreenFrame;
  
  BOOL isFullScreenMode;
  - (void)viewDidLoad {
      // Loading test image
          imageView.image = [UIImage   imageNamed:@"image1.jpg"];
      //---tap gesture---
      isFullScreenMode = NO;
  
      originalFrame = CGRectMake(imageView.frame.origin.x,imageView.frame.origin.y,imageView.frame.size.width,imageView.frame.size.height);
  
  
      //changes
      fullScreenFrame = CGRectMake(0,0,768,1004);
      UITapGestureRecognizer *tapGesture =
      [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
  
      tapGesture.numberOfTapsRequired = 2;
      [imageView addGestureRecognizer:tapGesture];
      [tapGesture release];
  
      //---pinch gesture---
      UIPinchGestureRecognizer *pinchGesture = 
      [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];
  
      [imageView addGestureRecognizer:pinchGesture];
      [pinchGesture release];   
  
      [super viewDidLoad];
  }
  
  //---handle tap gesture---
  -(IBAction) handleTapGesture:(UIGestureRecognizer *) sender {
      // HOW TO ACCOMPLISH THIS PART
      if (isFullScreenMode)
          [imageView setFrame:originalFrame];
      else
          [imageView setFrame:fullScreenFrame];
  
      [imageView setCenter:CGPointMake(self.view.frame.size.width/2,self.view.frame.size.height/2)];
      isFullScreenMode = !isFullScreenMode;
      NSLog(@"Image View : %@",imageView);
  }
  
  //---handle pinch gesture---
  -(IBAction) handlePinchGesture:(UIGestureRecognizer *) sender { 
      CGFloat factor = [(UIPinchGestureRecognizer *) sender scale];   
  
      if (sender.state == UIGestureRecognizerStateEnded){
          // HOW TO ACCOMPLISH THIS ---
          if (factor &gt; 1 &amp;&amp; !isFullScreenMode) {
              //---pinching in---
              [imageView setFrame:fullScreenFrame];
  
          } else {
              //---pinching out---
              [imageView setFrame:originalFrame];
  
          } 
          isFullScreenMode = !isFullScreenMode;
          [imageView setCenter:CGPointMake(self.view.frame.size.width/2,self.view.frame.size.height/2)];
      }   
      NSLog(@"Image View : %@",imageView);
  }
  
  - (void)didReceiveMemoryWarning {
      // Releases the view if it doesn't have a superview.
      [super didReceiveMemoryWarning];
  
      // Release any cached data, images, etc that aren't in use.
  }
  
  - (void)viewDidUnload {
      // Release any retained subviews of the main view.
      // e.g. self.myOutlet = nil;
  }
  
  - (void)dealloc {
      [images release];
      [imageView release];
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>Thanks.</p>