title: Perform custom animation with custom frame images
body: <p>I'm using storyboard. I have a 2 UIViewControler: view1 and view2.
  When pressing any of 6 button on view1 a segue is performed and therefore this method is called: prepareForSegue:. Now I would like to animate the view1 before it performs the segue with 6 custom images called navExitFrame1, navExitFrame2... and then show a default animation set in the storyboard under Modal>flip horizontal.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I am now using this code:</p>
  
  <pre><code>    void (^animationBlock)() = ^{
  
          NSArray *images = @[[UIImage imageNamed:@"navExitFrame1.png"],
                              [UIImage imageNamed:@"navExitFrame2.png"],
                              [UIImage imageNamed:@"navExitFrame3.png"],
                              [UIImage imageNamed:@"navExitFrame4.png"],
                              [UIImage imageNamed:@"navExitFrame5.png"],
                              [UIImage imageNamed:@"navExitFrame6.png"]];
  
          UIImage *myimage = [UIImage imageNamed:@"profile.png"];
  
          [profileButton.imageView setImage:myimage];
  
          [self.view bringSubviewToFront:imageView];
          imageView.hidden = NO;
  
          NSUInteger imagesCount = [images count];
  
          for(NSUInteger i=0; i&lt;imagesCount; i++) {
  
              [UIView addKeyframeWithRelativeStartTime:i/(CGFloat)imagesCount
                                      relativeDuration:1/(CGFloat)imagesCount
                                            animations:^{
  
                                                imageView.image = images[i];
  
                                            }];
          }
      };
  
      [UIView animateKeyframesWithDuration:1 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeDiscrete animations:animationBlock completion:^(BOOL finished) {
  
          if (sender == feelingsButton) {
  
              NSString *save = @"feelings";
              [[NSUserDefaults standardUserDefaults] setObject:save forKey:@"segueID"];
  
          } else if (sender == placesButton) {
  
              NSString *save = @"places";
              [[NSUserDefaults standardUserDefaults] setObject:save forKey:@"segueID"];
  
          }else if (sender == peopleButton) {
  
              NSString *save = @"people";
              [[NSUserDefaults standardUserDefaults] setObject:save forKey:@"segueID"];
  
          }else if (sender == settingsButton) {
  
              NSString *save = @"settings";
              [[NSUserDefaults standardUserDefaults] setObject:save forKey:@"segueID"];
  
          }else if (sender == profileButton) {
  
              NSString *save = @"profile";
              [[NSUserDefaults standardUserDefaults] setObject:save forKey:@"segueID"];
  
          }else if (sender == mainWebView || sender == mainWebView.gestureRecognizers) {
  
              NSString *save = @"newsfeed";
              [[NSUserDefaults standardUserDefaults] setObject:save forKey:@"segueID"];
          }
  
         [self performSegueWithIdentifier:@"ContentVWS" sender:nil];
  
      }];
  }
  </code></pre>
  
  <p>What is happening here is that the animation is taking place but in the space of a MICROsecond, I tried modifying the value of the Duration in </p>
  
  <p>animateKeyframesWithDuration:1 </p>
  
  <p>but nothing changes. Also after putting a breakpoint in the for loop I realise that no images are shown except for the last one but when I go in the build phases the images are listed as copy resource bundle and the image names are spelled correctly possibly that is why it is taking place in such a short period of time. Also maybe the values of  </p>
  
  <pre><code>UIView animateKeyframesWithDuration:1 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeDiscrete animations:animationBlock completion:^(BOOL finished) {
  </code></pre>
  
  <p>are incorrect, I NSloged them in the completion but only the variable i is correct and imagesCount is correct too but when I do i/(CGFloat)imagesCount is seems to always be returning 0 for some reason. Does that have anything to do with it?</p>