Skip to content

Instantly share code, notes, and snippets.

@ezefranca
Forked from aaronwardle/sharedButtonCode
Created November 9, 2015 20:54
Show Gist options
  • Save ezefranca/5fc4dad814f3c57ea068 to your computer and use it in GitHub Desktop.
Save ezefranca/5fc4dad814f3c57ea068 to your computer and use it in GitHub Desktop.
UIActivityViewController Example
- (void)shareButtonClicked {
//-- set strings and URLs
NSString *textObject = @"Information that I want to tweet or share";
NSString *urlString = [NSString stringWithFormat:@"http://www.mygreatdomain/%@", _selectedPageString];
NSURL *url = [NSURL URLWithString:urlString];
NSArray *activityItems = [NSArray arrayWithObjects:textObject, url, nil];
//-- initialising the activity view controller
UIActivityViewController *avc = [[UIActivityViewController alloc]
initWithActivityItems:activityItems
applicationActivities:nil];
avc.excludedActivityTypes = @[UIActivityTypePostToWeibo, UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard ];
//-- define the activity view completion handler
avc.completionHandler = ^(NSString *activityType, BOOL completed){
if (completed) {
// NSLog(@"Selected activity was performed.");
} else {
if (activityType == NULL) {
// NSLog(@"User dismissed the view controller without making a selection.");
} else {
// NSLog(@"Activity was not performed.");
}
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment