首先導(dǎo)入系統(tǒng)類庫(kù)
social.framework
導(dǎo)入頭文件:
#import <Social/social.h>
之后使用UIActivityViewController顯示分享選項(xiàng)剩拢,代碼如下: (增加微信分享)
NSArray*activity = @[[[WeixinSessionActivityalloc]init], [[WeixinTimelineActivityalloc]init]];
UIActivityViewController*activityView?=?[[UIActivityViewControlleralloc]initWithActivityItems:@[@"這里是標(biāo)題",?[NSURLURLWithString:@"http://www.google.com"]]applicationActivities:activity];
activityView.excludedActivityTypes=?@[UIActivityTypeAssignToContact,?UIActivityTypeCopyToPasteboard,?UIActivityTypePrint,UIActivityTypePostToWeibo];
[selfpresentViewController:activityViewanimated:YEScompletion:nil];