LinkedIn & Google+ UIActivity View Controller Button?

筅森魡賤 提交于 2020-01-11 07:29:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!