gpt4 book ai didi

ios - UIActivityViewController为WhatsApp或Facebook选择了不同的文本

转载 作者:行者123 更新时间:2023-12-01 17:24:35 25 4
gpt4 key购买 nike

我在 Activity 项目中有文本,但现在它在WhatsApp或Facebook上共享,此方法为每个应用共享相同的文本。
每个应用程序可以共享不同的文本吗?

- (void)share {
NSString *text = @"share test";

NSArray * activityItems = @[[NSString stringWithFormat:@"%@", text], [NSURL URLWithString:@"http://www.test.co"]];
NSArray * applicationActivities = nil;
NSArray * excludeActivities = @[UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard, UIActivityTypePostToWeibo, UIActivityTypePrint, UIActivityTypeMessage];

UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityController.excludedActivityTypes = excludeActivities;

[self presentViewController:activityController animated:YES completion:nil];

[activityController setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
NSLog(@"The setCompletionWithItemsHandler completed = %i", completed);

if (completed) {
NSLog(@"The selected activity was %@", activityType);

if ( [activityType isEqualToString:UIActivityTypeMail]) {
NSLog(@"Mail sended");
} else if ( [activityType isEqualToString:UIActivityTypePostToTwitter]) {
NSLog(@"Post on twitter, ok!");
} else if ( [activityType isEqualToString:UIActivityTypePostToFacebook]) {
NSLog(@"Post on facebook, ok!");
} else if ( [activityType isEqualToString:UIActivityTypeMessage]) {
NSLog(@"SMS sended!");
}
}
}];
}

最佳答案

简短答案:不可以。

但是您可以使用带有URL方法的打开应用程序,并将参数传递给该应用程序。
使用该方法时,必须使用自定义UI,并且不能使用UIActivityViewController。 (我所知道的)

因此,如果您想拥有多个按钮,例如:
“与WhatsApp共享”
“与Facebook分享”
等等

关于ios - UIActivityViewController为WhatsApp或Facebook选择了不同的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43519969/

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