Reputation: 1024
I just added sharekit to my project. Is its action only possible by the use of "share" button in navigationbar? I have a table view and I would like to use the share action by pressing a cell. it is possible (eventually separating differente service in differente cell)?
Thanks in advance
Upvotes: 1
Views: 182
Reputation: 18551
Its definitely possible. Checkout UITableView
's delegate method for didSelectRowAtIndex:
. Then in your implementation just call the appropriate share kit service.
// Check if the SLComposeViewController is available.
if (NSClassFromString(@"SLComposeViewController")) {
SLComposeViewController *FBPostSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[FBPostSheet setInitialText:@"I'm posting to Facebook!"];
[FBPostSheet addURL:[NSURL URLWithString:@"http://www.Apple.com"]];
[FBPostSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
NSLog(@"Cancelled");
break;
case SLComposeViewControllerResultDone:
NSLog(@"Cancelled");
break;
}
}];
// Apparently its possible for composeViewControllerForServiceType: to return nil... better check.
if (FBPostSheet) {
[self presentViewController:FBPostSheet animated:YES completion:nil];
} else {
NSLog(@"Error Creating Post Sheet");
}
}
Upvotes: 1