Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save verma-manish58/03ac68ed926476d7490f to your computer and use it in GitHub Desktop.
Save verma-manish58/03ac68ed926476d7490f to your computer and use it in GitHub Desktop.
UIActivityViewController tips
NSString *string = @"Text to share"
UIImage *image = [UIImage imageNamed:@"imageToShare"];
NSURL *URL = [NSURL URLWithString:@"relativeUrl"];

// Integrate with WeChat
NSArray *activity = @[[[WeixinSessionActivity alloc] init], [[WeixinTimelineActivity alloc] init]];

UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[string, image, URL] applicationActivities:activity];
[self.navigationController presentViewController:activityViewController animated:YES completion:nil];

注:微信需要在 application:didFinishLaunchingWithOptions: 中注册 app:

[WXApi registerApp:@"appId"];

这是从微信、微博等跳回来需要的设置,(注,微博的URL Schemes需在 appId 前面加 wb,微信的自带了 wx) : TARGETS -> Info -> URL Types -> 编辑 URL Schemes:添加唯一的字符串

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment