title: Swipe gesture detected but no image is displayed (UISwipeGestureRecognizer, UIImageView and NSArray)
body: <p>I am trying to swipe between 2 images. The gesture is recognized but no image is displayed.</p>
  
  <p>I am attempting to do it programmatically. At first I am creating an UIImageView that I have declared in the .h file. That image view is called imageView.</p>
  
  <p>In the .m file I am implementing that view. I have also added Swipe left and right gesture recognizers. The swipes trigger an action called handleSwipe. I know that the swipes are recognized because of an NSLog statement that is shown in my output log when a swipe occurs.</p>
  
  <p>The handleSwipe action get an image from an NSArray and displays it based on whether we swipe left or right. That method put the image in imageView.</p>
  
  <p>The problem I have is that I have is that handleSwipe does not display any image.</p>
  
  <p>My code is below:</p>
  
  <pre><code>@implementation firstStartViewController
  @synthesize imageView;
  int imageIndex = 1;
  
  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  if (self) {
      // Custom initialization
  }
  return self;
  }
  - (void)viewDidLoad
  {
  [super viewDidLoad];
  // Do any additional setup after loading the view.
  self.view.backgroundColor = [UIColor whiteColor];
  
  
  imageView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds));
  
  imageView.center = CGPointMake(CGRectGetWidth(self.view.bounds)/2.0f, CGRectGetHeight(self.view.bounds)/2.0f + 75);
  
  imageView.userInteractionEnabled = YES;
  
  [self.view addSubview:imageView];
  
  
  
  UISwipeGestureRecognizer *swipeleft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
  swipeleft.direction = UISwipeGestureRecognizerDirectionLeft;
  [self.view addGestureRecognizer:swipeleft];
  
  
  
  UISwipeGestureRecognizer *swiperight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
  swiperight.direction = UISwipeGestureRecognizerDirectionRight;
  [self.view addGestureRecognizer:swiperight];
  
  
  UIBarButtonItem *dismiss_btn = [[UIBarButtonItem alloc] initWithTitle:@"Start App" style:UIBarButtonItemStylePlain target:self action:@selector(dismissModal:)];
  
  self.navigationItem.rightBarButtonItems = [NSMutableArray arrayWithObjects:dismiss_btn, nil];
  }
  
  
  - (IBAction)handleSwipe:(UIGestureRecognizer *)sender {
  
  NSLog( @"Swiped");
  
  
  NSArray *images=[[NSArray alloc] initWithObjects:
                   @"image1.png",
                   @"image2.png", nil];
  
  UISwipeGestureRecognizerDirection direction = [(UISwipeGestureRecognizer *) sender direction];
  
  switch (direction) {
      case UISwipeGestureRecognizerDirectionLeft:
          imageIndex++;
          break;
      case UISwipeGestureRecognizerDirectionRight:
          imageIndex--;
          break;
      default:
          break;
  }
  imageIndex = (imageIndex &lt; 0) ? ([images count] -1): imageIndex % [images count];
  imageView.image = [UIImage imageNamed:[images objectAtIndex:imageIndex]];
  }
  </code></pre>