我正在尝试执行显示取消或成功警报的简单任务,这取决于用户是否已发布或取消共享。我正在使用 iOS 6 共享功能,如下所述:
NSArray *activityItems = @[textToShare, urlToShare];
UIActivityViewController *activityVC = [[UIActivityViewController
alloc]initWithActivityItems:activityItems applicationActivities:nil];
[activityVC setExcludedActivityTypes:[NSArray arrayWithObjects:
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypePostToWeibo,
UIActivityTypePrint,
UIActivityTypeSaveToCameraRoll,
nil]];
[self presentViewController:activityVC animated:TRUE completion:nil];
我可以通过使用 Facebook 的 SLServiceType 来获得一个取消/成功的警报,如下所述,但我似乎无法让它适用于上面的简单 activityVC 版本。任何帮助,将不胜感激!
- (IBAction)facebookPost:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *mySLComposerSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:@"Sample Share"];
[mySLComposerSheet addImage:[UIImage imageNamed:@"myImage.png"]];
[mySLComposerSheet addURL:[NSURL URLWithString:@"http://www.website.com"]];
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case 0:
{
SLComposeViewControllerResultCancelled:
NSLog(@"Post Canceled");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cancelled"
message:@"You must be connected to the internet to use this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
break;
}
case 1:
{
SLComposeViewControllerResultDone:
NSLog(@"Post Sucessful");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Successful"
message:@"You must be connected to the internet to use this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
break;
}
default:
break;
}
}];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
}