iOS自带的分享功能


方法一

添加Social.framework至工程

-(IBAction)btnFacebookSharing_Clicked:(id)sender {

    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
       SLComposeViewController * fbSheetOBJ = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
 
        [fbSheetOBJ setInitialText:@"Post from my iOS application"];
        [fbSheetOBJ addURL:[NSURL URLWithString:@"http://www.weblineindia.com"]];
        [fbSheetOBJ addImage:[UIImage imageNamed:@"my_image_to_share.png"]];
 
        [self presentViewController:fbSheetOBJ animated:YES completion:Nil];
    }

}


方法二


- (IBAction)sharingaction:(id)sender {
    
    NSString *eventNameToShare = [NSString stringWithFormat:@"%@",_eventnameText];//要分享的标题
    NSURL* bannerURL = [NSURL URLWithString:_bannerimageText];//要分享的图片链接
    NSData* bannerdata = [[NSData alloc] initWithContentsOfURL:bannerURL];
    UIImage *imageToShare = [UIImage imageWithData:bannerdata];
    NSString *eventDetailToShare = [NSString stringWithFormat:@"%@",_eventdetailText];/要分享的具体文字
    NSArray *itemsToShare = @[eventNameToShare, imageToShare, eventDetailToShare];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
    activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll]; //or whichever you don't need
    [self presentViewController:activityVC animated:YES completion:nil];
}

阅读更多
上一篇设置过滤器过滤一个月以外的内容
下一篇IOS常用的第三方库和使用方法
想对作者说点什么? 我来说一句

iOS系统自带各平台分享功能

2016年02月01日 84KB 下载

没有更多推荐了,返回首页

关闭
关闭