• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - UIActivityViewController 和注释

[复制链接]
菜鸟教程小白 发表于 2022-12-13 11:43:46 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我的应用程序中有 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)activityViewControllerUIActivityViewController *)activityViewController itemForActivityTypeNSString *)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)activityViewControllerPlaceholderItemUIActivityViewController *)activityViewController {
    return @"Some string";
}

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



Best Answer-推荐答案


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

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

- (id)activityViewControllerUIActivityViewController *)activityViewController itemForActivityTypeNSString *)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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap