gpt4 book ai didi

ios - UIActivityViewController 和注释

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

我的应用程序中有 UIActivityViewController 用于诸如发布到 Facebook 之类的事情,但它也添加了 Notes 作为选项,但由于没有用于 Notes 的 UIActivityType,我不能排除它,但它也没有向 Notes 添加任何内容。我的代码是:

Mail *mail = [[Mail alloc]init];
NSString *html = self.finalObject[@"Request"];
NSString *thetitle = [self.finalObject[@"Title"] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSString *thedate = self.finalObject[@"dateMade"];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MMM_dd_yyyy"];
[dateFormat setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
NSDate *theNewDate1 = [dateFormat dateFromString:thedate];
NSString *theNewDate = [dateFormat stringFromDate:theNewDate1];

mail.thehtml = html;
self.nameofhtmlfile = [[[[@"http://www.iprayed4u.net/app/" stringByAppendingString:thetitle] stringByAppendingString:@"_"] stringByAppendingString:theNewDate] stringByAppendingString:@".html"];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[self] applicationActivities:@[mail]];



activityVC.excludedActivityTypes = @[ UIActivityTypePostToWeibo,

UIActivityTypeCopyToPasteboard,

UIActivityTypeAssignToContact,
UIActivityTypeMail,
UIActivityTypePrint,
UIActivityTypeAirDrop
];



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

- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {

if ([activityType isEqualToString:UIActivityTypePostToTwitter]){
NSString *test = [[@"I just pledged to pray. You can pray too, just click " stringByAppendingString:self.nameofhtmlfile] stringByAppendingString:@" to view request. Get #iPrayed4U here https://appsto.re/us/p_t30.i"];
return test;
}
if ([activityType isEqualToString:UIActivityTypePostToFacebook]){
NSString *test = [[[[[@"'" stringByAppendingString:self.finalObject[@"Title"]] stringByAppendingString:@"'. "] stringByAppendingString:@"I just pledged to pray. You can pray too, just click " ] stringByAppendingString:self.nameofhtmlfile] stringByAppendingString:@" to view request. You can also get the app for free. Check out iPrayed 4 U on iOS at https://appsto.re/us/p_t30.i #iPrayed4U"];
return test;
}
if ([activityType isEqualToString:UIActivityTypeMessage]){
NSString *test = [[[[[@"'" stringByAppendingString:self.finalObject[@"Title"]] stringByAppendingString:@"'. "] stringByAppendingString:@"I just pledged to pray. You can pray too, just click " ] stringByAppendingString:self.nameofhtmlfile] stringByAppendingString:@" to view request. You can also get the app for free. Check out iPrayed 4 U on iOS at https://appsto.re/us/p_t30.i #iPrayed4U"];
return test;
}
return nil;
}
- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
return @"Some string";
}

我怎样才能让它从 UIActivityViewController 中删除 Notes,或者让它实际工作?

最佳答案

您不能排除 Notes,因为它不是系统事件:它是共享扩展。只有用户可以决定是否包含它或排除它。

现在您已经添加了其余代码,您可以了解为什么 Notes 不保存任何内容:您没有向它传递任何数据。当 Notes 请求数据时,您将返回 nil:

- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {
if ([activityType isEqualToString:UIActivityTypePostToTwitter]){
}
if ([activityType isEqualToString:UIActivityTypePostToFacebook]){
}
if ([activityType isEqualToString:UIActivityTypeMessage]){
}
return nil; // this is what you are sending to Notes
}

关于ios - UIActivityViewController 和注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32878426/

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