菜鸟教程小白 发表于 2022-12-13 11:43:46

ios - UIActivityViewController 和注释


                                            <p><p>我的应用程序中有 UIActivityViewController 用于发布到 Facebook 等内容,但它也作为选项添加到 Notes 中,但由于 Notes 没有 UIActivityType,我无法排除它,但它也没有向 Notes 添加任何内容。我的代码是:</p>

<pre><code>Mail *mail = [init];
    NSString *html = self.finalObject[@&#34;Request&#34;];
    NSString *thetitle = stringByReplacingOccurrencesOfString:@&#34; &#34; withString:@&#34;%20&#34;];
    NSString *thedate = self.finalObject[@&#34;dateMade&#34;];
    NSDateFormatter *dateFormat = [ init];
    ;
    ];
    NSDate *theNewDate1 = ;
    NSString *theNewDate = ;

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

    UIActivityViewController *activityVC = [ initWithActivityItems:@ applicationActivities:@];



      activityVC.excludedActivityTypes = @[ UIActivityTypePostToWeibo,

                                              UIActivityTypeCopyToPasteboard,

                                              UIActivityTypeAssignToContact,
                                              UIActivityTypeMail,
                                              UIActivityTypePrint,
                                              UIActivityTypeAirDrop
                                              ];



    ;

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

    if (){
      NSString *test = [[@&#34;I just pledged to pray.You can pray too, just click &#34; stringByAppendingString:self.nameofhtmlfile] stringByAppendingString:@&#34; to view request.Get #iPrayed4U here https://appsto.re/us/p_t30.i&#34;];
      return test;
    }
    if (){
      NSString *test = [[[[[@&#34;&#39;&#34; stringByAppendingString:self.finalObject[@&#34;Title&#34;]] stringByAppendingString:@&#34;&#39;.&#34;] stringByAppendingString:@&#34;I just pledged to pray.You can pray too, just click &#34; ] stringByAppendingString:self.nameofhtmlfile] stringByAppendingString:@&#34; 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&#34;];
      return test;
    }
    if (){
      NSString *test = [[[[[@&#34;&#39;&#34; stringByAppendingString:self.finalObject[@&#34;Title&#34;]] stringByAppendingString:@&#34;&#39;.&#34;] stringByAppendingString:@&#34;I just pledged to pray.You can pray too, just click &#34; ] stringByAppendingString:self.nameofhtmlfile] stringByAppendingString:@&#34; 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&#34;];
      return test;
    }
    return nil;
}
- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
    return @&#34;Some string&#34;;
}
</code></pre>

<p>我怎样才能让它从 UIActivityViewController 中删除 Notes,或者让它实际工作?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您不能排除 Notes,因为它不是系统事件:它是共享扩展。只有用户可以决定是包含它还是排除它。</p>

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

<pre><code>- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {
    if (){
    }
    if (){
    }
    if (){
    }
    return nil; // this is what you are sending to Notes
}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - UIActivityViewController 和注释,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/32878426/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/32878426/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - UIActivityViewController 和注释