gpt4 book ai didi

ios - 如何知道在 activityController setCompletionHandler 被调用之前 UIActivityViewController 中点击了哪个图标?

转载 作者:行者123 更新时间:2023-11-28 20:01:48 25 4
gpt4 key购买 nike

如何知道在调用 activityController setCompletionHandler:^(NSString *activityType, BOOL completed) 之前在 UIActivityViewController 中单击了哪个图标?

我想在 Twitter 和 Facebook 上分享不同的文字。

-(IBAction)btnSharePressedFromOffersDetail:(id)sender
{
NSString *posturl= @"facebook or twitter";
UISimpleTextPrintFormatter *printData = [[UISimpleTextPrintFormatter alloc]init];
NSArray *Itemsarray=@[posturl,printData];
UIActivityViewController *activityController = [[UIActivityViewController alloc]initWithActivityItems:Itemsarray applicationActivities:nil];
[self presentViewController:activityController
animated:YES completion:nil];
[activityController setCompletionHandler:^(NSString *activityType, BOOL completed)
{
NSLog(@"Activity = %@",activityType);
NSLog(@"Completed Status = %d",completed);
if (completed)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@""
message:@"Thanks for sharing!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
else
{
}
}];
}

最佳答案

如果您的目标是为 Twitter 或 Facebook 使用不同的文本,则由实现 UIActivityItemSource 协议(protocol)的共享模型负责。

- (id) activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType
{
if([activityType isEqualToString:UIActivityTypePostToFacebook]) return @"Facebook text";
else if([activityType UIActivityTypePostToTwitter]) return @"Twitter text";
else return @"Default text";
}

关于ios - 如何知道在 activityController setCompletionHandler 被调用之前 UIActivityViewController 中点击了哪个图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23708974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com