问题
I understand that there is a Facebook & Twitter button for the UIActivity View Controller, but I was wandering if there was a service for sharing to Google+ or LinkedIn through the UIActivityViewController?
回答1:
There is not one for each available in apple provided types, but you can create your own. You can create an UIActivity
class and pass it into the UIActivityViewController
to handle sending data to each of the services you are looking to interactive with:
DataItemProvider *dataToShare = [[DataItemProvider alloc] initWithPlaceholderItem:FileTypeToShare];
GooglePlusActivityType *googleActivity = [[GooglePlusActivityType alloc] init];
LinkdInActivityType *linkdinActivity = [[LinkdInActivityType alloc] init];
NSArray *activityTypes = @[googleActivity, linkdinActivity];
NSArray *activityItems = @[dataToShare];
UIActivityViewController *activityController = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:activityTypes];
[activityController setCompletionHandler:^(NSString *activityType, BOOL completed) {
//Put in your completion handle code here.
}];
[self presentViewController:activityController animated:YES completion:nil];
Then implement classes for both GooglePlusActivityType
and LinkdInActivityType
to handle loading the data to the two sites.
来源:https://stackoverflow.com/questions/15600082/linkedin-google-uiactivity-view-controller-button