调用iOS系统分享


NSString *shareText = @"sharetitle";
    UIImage *shareImage = [UIImage imageNamed:@"167x167.png"];
    NSURL *shareURL = [NSURL URLWithString:@"https://www.baidu.com/"];
    NSArray *activityItems = [[NSArray alloc] initWithObjects:shareText, shareImage, shareURL, nil];
    
    UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
    
    UIActivityViewControllerCompletionWithItemsHandler myBlock = ^(UIActivityType activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
        NSLog(@"%@",activityType);
        if (completed) {
            NSLog(@"分享成功");
        } else {
            NSLog(@"分享失败");
        }
        [vc dismissViewControllerAnimated:YES completion:nil];
    };
    
    vc.completionWithItemsHandler = myBlock;
    
    [self presentViewController:vc animated:YES completion:nil];

结果如下:

调用iOS系统分享_第1张图片
IMG_6655.PNG
调用iOS系统分享_第2张图片
IMG_6656.PNG
调用iOS系统分享_第3张图片
IMG_6658.PNG

你可能感兴趣的:(调用iOS系统分享)