title: GIF do not animate when share on twitter
body: <p>I am creating animated GIF file with <code>NSArray</code> of <code>UIImage</code>. And saving it in <code>NSDocumentDirectory</code> as well as in Photo Album of iPhone.</p>
  
  <p>The problem I am facing is, when I open the saved GIF in Email Composer or in iMessage, it animates fine. But when i share it through twitter, it does not animate. I tried sharing through twitter app on iPhone and saw an Interesting thing(ScreenShot below) that The GIFs i downloaded from different websites using Safari shows a label 'GIF' on top left corner of GIF. While my saved GIFs does not. What might be the problem here? Can anyone please guide me.</p>
  
  <p><img src="https://i.stack.imgur.com/27KOW.png" alt="enter image description here"></p>
  
  <p>Here is the code for creating the GIF file:</p>
  
  <pre><code>float delay = 1.0/15.0; // 15 FPS
  
  NSDictionary *prep = @{
                         (__bridge id)kCGImagePropertyGIFDictionary: @{
                                 (__bridge id)kCGImagePropertyGIFDelayTime: @(delay) 
                                 }
                         };
  
  //    static NSUInteger kFrameCount = 16;
  
  NSDictionary *fileProperties = @{
                                   (__bridge id)kCGImagePropertyGIFDictionary: @{
                                           (__bridge id)kCGImagePropertyGIFLoopCount: @0 // 0 means loop forever
                                           }
                                   };
  
  CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:path];
  
  CGImageDestinationRef dst = CGImageDestinationCreateWithURL(url, kUTTypeGIF, [images count], nil);
  CGImageDestinationSetProperties(dst, (__bridge CFDictionaryRef)fileProperties);
  
  for (int i=0;i&lt;[images count];i++)
  {
          //load anImage from array
          UIImage * anImage = [images objectAtIndex:i];
  
          CGImageDestinationAddImage(dst, anImage.CGImage,(__bridge CFDictionaryRef)prep);
  
  }
  
  bool fileSave = CGImageDestinationFinalize(dst);
  CFRelease(dst);
  if(fileSave) {
      NSLog(@"animated GIF file created at %@", path);
  }else{
      NSLog(@"error: no animated GIF file created at %@", path);
  }
  </code></pre>
  
  <p>And saving the GIF into Photo Album as well as in NSDocumentDirectory. To save in Photo Album of iPhone, here is the code:</p>
  
  <pre><code>ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
  
  NSData *data = [NSData dataWithContentsOfFile:tempPath];
  
  [library writeImageDataToSavedPhotosAlbum:data metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) {
      if (error) {
          NSLog(@"Error Saving GIF to Photo Album: %@", error);
      } else {
          // TODO: success handling
          NSLog(@"GIF Saved to %@", assetURL);
  
          success(tempPath);
      }
  }];
  </code></pre>
  
  <p><a href="https://github.com/HarrisonJackson/HJImagesToGIF" rel="nofollow noreferrer">HJImagesToGIF</a> was big help, as well as <a href="https://gist.github.com/mayoff/4969104" rel="nofollow noreferrer">this gist</a>!</p>
  
  <p><strong>UPDATE:</strong> </p>
  
  <p>On analysing the Image Header of 2 GIFs:
  1- Image Header: <strong>GIF89a</strong> - downloaded through safari and shows GIF label in twitter app
  2- Image Header: <strong>GIF87a</strong> - Created through code, doesnt show GIF label in twitter app</p>
  
  <p>So the Image Header! hmmm.. how do I change it?</p>