How to share an gif animated images in iOS

后端 未结 4 1998
野性不改
野性不改 2020-12-20 03:42

I am not getting any idea about sharing an animated .gif images using UIActivityViewController.please help me to resolve this.thanks in advance

see this imag         


        
4条回答
  •  暖寄归人
    2020-12-20 04:28

    FWIW, I was having the same problem when trying to include a UIImage in the ActivityItems array. It will not work w/ a generic UIImage, nor a UIImage using the UIImage+animagedGIF category, nor FLAnimatedImage.

    To resolve this problem, at least on iOS8, simply add the gif to the ActivityItems array as an NSData object rather than UIImage.

    For example, assuming the gif is being requested from a URL:

    NSURL *imagePath = [NSURL URLWithString:@"http://i.imgur.com/X4oonnm.gif"];
    NSData *animatedGif = [NSData dataWithContentsOfURL:imagePath];
    NSArray *sharingItems = [NSArray arrayWithObjects: animatedGif, nil];
    
    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
    

提交回复
热议问题