将Instagram添加到UIActivityViewController Share Swift

时间:2014-12-07 22:04:19

标签: swift instagram uiactivityviewcontroller

我之前在Obj-C中实现了这个,但是无法使它在swift上运行。我希望能够分享照片到Instagram以及其他标准应用程序。

- (IBAction)thirdOne:(id)sender {
    NSDictionary *fruitParams = [NSDictionary dictionaryWithObjectsAndKeys:self.fruitName, @"Fruit Name",nil];

    NSString* imagePath = [NSString stringWithFormat:@"%@/instagramShare.igo", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]];
    [[NSFileManager defaultManager] removeItemAtPath:imagePath error:nil];

    UIImage *instagramImage = self.image;
    [UIImagePNGRepresentation(instagramImage) writeToFile:imagePath atomically:YES];

    self.dic=[UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:imagePath]];
    self.dic.UTI = @"com.instagram.exclusivegram";
    [self.dic presentOpenInMenuFromRect: self.view.frame inView:self.view animated:YES ];
}

按钮的外观如下:

fruit face ios instagram share

这就是单击按钮时发生的情况:

fruit face ios instagram will smith

0 个答案:

没有答案