gpt4 book ai didi

ios - UIActivityViewController 中各个事件事件的不同事件项目

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:09:21 25 4
gpt4 key购买 nike

是否可以为 UIActivityViewController 中的每个事件使用不同的事件项?例如,我有以下代码:

NSArray *objectsToShare = @[schemeURL, wordedString];
controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];

// Exclude all activities except AirDrop.
NSArray *excludedActivities = @[UIActivityTypePostToTwitter,
UIActivityTypePostToWeibo,
UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo];
controller.excludedActivityTypes = excludedActivities;
[self presentViewController:controller animated:YES completion:nil];

我想将要发送到 Facebook 的数据设置到 wordedString 属性,并将数据设置为通过 AirDrop 发送到属性 schemeURL。这可能吗?提前致谢。

最佳答案

您可以子类化 UIActivityItemProvider 并且可以使用以下方法来检查事件类型..试试吧

//- Returns the data object to be acted upon. (required)
- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType
{
if ([activityType isEqualToString:UIActivityTypePostToFacebook]) {
NSString *theText = @"Some text for Facebook";
return theText;
}

if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {
NSString *theText = @"Some text for Twitter";
return theText;
}

if ([activityType isEqualToString:UIActivityTypePostToWeibo]) {
NSString *theText = @"Some text for Weibo";
return theText;
}

if ([activityType isEqualToString:UIActivityTypeMail]) {
NSString *theText = _someText;
return theText;
}

if ([activityType isEqualToString:kYourCustomMailType]) {
NSString *theText = @"Some text for your Custom Type";
return theText;
}

return @"Some default text";

关于ios - UIActivityViewController 中各个事件事件的不同事件项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20176574/

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