我正在使用UIActivityViewController
,因为我添加了脸书,推特和邮件。在使用这些功能中的任何一个完成共享活动之后,我如何才能获得成功回调。
任何想法都可以被感激,
答案 0 :(得分:11)
Swift语法:
{{1}}
答案 1 :(得分:7)
像这样设置完成处理程序
[controller setCompletionHandler:^(NSString *act, BOOL success)
{
NSLog(@"act type %@",act);
NSString *result = nil;
if ( [act isEqualToString:UIActivityTypePostToTwitter] ) result = @"POST-SHARED-SUCCESSFULLY";
if ( [act isEqualToString:UIActivityTypePostToFacebook] ) result = @"POST-SHARED-SUCCESSFULLY";
if (success)
{
UIAlertView *av = [[UIAlertView alloc] initWithTitle:result message:nil delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil];
[av show];
}
else
{
UIAlertView *av = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"ERROR", nil) message:nil delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil];
[av show];
}
}];
答案 2 :(得分:0)
setCompletionHandler
已过时。因此,如果您使用的是iOS 8.0+,那么这里就是解决方案。
activityViewController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
// When the completed flag is YES, the user performed a specific activity
};