iOS UIActivityViewController分享

    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{

//分享失败

          }

}

posted @ 2020-02-06 15:58  snbill  阅读(606)  评论(0编辑  收藏  举报