码迷,mamicode.com
首页 > 移动开发 > 详细

iOS UIActivityViewController分享

时间:2020-02-06 16:16:50      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:ati   sel   pre   bsp   app   equal   har   pat   elf   

    NSArray*activityItems;

    //IMAGE

    if([strType isEqual:@"IMAGE"])

    {

        UIImage*imageToShare = _iv.image;

        activityItems =@[imageToShare];

    }else

    {

        NSURL*shareURL = [NSURL fileURLWithPath:strPDFURL];

        activityItems =@[shareURL];

    }

    UIActivityViewController *avc = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];

    [self presentViewController:avc animated:YES completion:nil];

    [avc setCompletionWithItemsHandler:^(NSString*__nullableactivityType,BOOL completed,NSArray*__nullablereturnedItems,NSError*__nullableactivityError){

        if(completed) {

//分享成功

        }else{

//分享失败

          }

}

iOS UIActivityViewController分享

标签:ati   sel   pre   bsp   app   equal   har   pat   elf   

原文地址:https://www.cnblogs.com/snbill/p/12268991.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!