Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.