iOS UIActivityViewController 接入WeChatSDK

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#import "ViewController.h"
#import "WeixinSessionActivity.h"
#import "WeixinTimelineActivity.h"

@interface ViewController ()
{
    NSArray *activities;
}

@end

@implementation ViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    activities = @[[[WeixinSessionActivity alloc] init],[[WeixinTimelineActivity alloc] init]];
    [self showActivityButton];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)showActivityButton
{
    UIButton* activityButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [activityButton setTitle:@"Activity" forState:UIControlStateNormal];
    [activityButton setFrame:CGRectMake(130, 200, 60, 30)];
    [activityButton addTarget:self action:@selector(showActivityView) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:activityButton];
}

- (void)showActivityView
{
    NSString* shareText = @"The text I am Sharing";
    UIImage* image = [UIImage imageNamed:@"icon"];
    NSURL *url = [NSURL URLWithString:@"www.baidu.com"];
    NSArray* itemsToShare = @[shareText,image,url];
    UIActivityViewController* activityViewController = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:activities];
    //去除特定的分享功能
    activityViewController.excludedActivityTypes = @[];
    [self presentViewController:activityViewController animated:YES completion:nil];
}

@end