How to share an gif animated images in iOS

后端 未结 4 1991
野性不改
野性不改 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:35

    This should do it. Expanding on Jordan Bonitatis' answer. The trick is to create an NSData object with the contents of the NSURL.

    - (void)share
    {
      NSURL *imageURL = [NSURL URLWithString:@"http://...url..of..gif];
      NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
      NSArray *objectsToShare = @[imageData];
    
      UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
    
      NSArray *excludeActivities = @[UIActivityTypeAirDrop,
                                     UIActivityTypePrint,
                                     UIActivityTypePostToVimeo];
    
      activityVC.excludedActivityTypes = excludeActivities;
    
      [self presentViewController:activityVC animated:YES completion:nil];
    }
    

提交回复
热议问题