Maybe you can try to create your UIImage
from the individual frames as UIImage
supports this through +(UIImage *)animatedImageWithImages:(NSArray *)images duration:(NSTimeInterval)duration
.
To get the frames from your NSData
you can do this, but first make sure to import <ImageIO/ImageIO.h>
and link your binary to that framework.
NSData *data = [NSData dataWithContentsOfFile:self.filepath];
NSMutableArray *frames = nil;
CGImageSourceRef sourceRef = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
if (sourceRef) {
size_t frameCount = CGImageSourceGetCount(sourceRef);
frames = [NSMutableArray arrayWithCapacity:frameCount];
for (size_t i = 0; i < frameCount; i++) {
CGImageRef image = CGImageSourceCreateImageAtIndex(sourceRef, i, NULL);
if (image) {
[frames addObject:[UIImage imageWithCGImage:image]];
CGImageRelease(image);
}
}
CFRelease(sourceRef);
}
Then after you have your frames you can create an animated UIImage
like so:
UIImage *animatedImage = [UIImage animatedImageWithImages:frames
duration: frames.count / 30.0];
Note this is assuming your gif is playing back at 30 frames per second. You can change this by changing 30 to your desired frame rate. Now you should be able to post like this:
[sheet addImage:animatedImage]
.