1

我使用下面的代码打开了 SnapChat,它只从我的应用程序中打开 SnapChat。

NSURL *appSnapChatURL = [NSURL URLWithString:@"snapchat://app"];
if([[UIApplication sharedApplication] canOpenURL:appSnapChatURL]) 
{
    [[UIApplication sharedApplication] openURL:appSnapChatURL];
}

现在我还需要一项功能,即如何在其中添加文本/图像/视频,以便我可以从我的应用程序在 SnapChat 上共享文本/图像/视频。

请帮忙。

4

2 回答 2

0
NSArray *activityItems = [NSArray arrayWithObjects:[NSString stringWithFormat:@"Sample text", nil];
    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
    activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    [activityViewController setCompletionHandler:^(NSString *act, BOOL done)
     {
         //Code here for completion handler
     }];
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
       [self presentViewController:activityViewController animated:YES completion:nil];
    }
    //if iPad
    else {
        // Change Rect to position Popover
        UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
        [popup presentPopoverFromRect:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/4, 0, 0)inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
于 2017-05-15T09:28:22.637 回答
0

Snapchat 在 iOS、Swift 中的共享。请按照以下教程进行操作。

Snapchat Creative Kit iOS (Swift) - 图片、视频、贴纸分享

于 2021-06-09T17:52:08.890 回答