Ios 如何仅使用共享扩展名共享图像或视频

Ios 如何仅使用共享扩展名共享图像或视频,ios,ios-app-extension,ios8-share-extension,Ios,Ios App Extension,Ios8 Share Extension,我想我的扩展支持文本,网址,视频和10个图像 我已将plist配置如下: 这项工作很好,但我想我的扩展不支持图像和视频在同一时间 我知道我很可能必须构建一个“SUBQUERY(…)”语句。 我的谓词是这样的: SUBQUERY ( extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment,( NOT ( ANY $attachment.registeredTypeIdentif

我想我的扩展支持文本,网址,视频和10个图像

我已将plist配置如下:

这项工作很好,但我想我的扩展不支持图像和视频在同一时间

我知道我很可能必须构建一个“SUBQUERY(…)”语句。 我的谓词是这样的:

SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,(
     NOT ( ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
           AND ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie")
     ) AND (
           ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
        || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text"
        || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
        || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
        || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text")
).@count < 10
).@count == 1
子查询(
伸展岩,
多边主义,
子查询(
$m.attachments,
$附件(
不(任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.image”
以及任何$attachment.registeredTypeIdentifiers UTI-compliance-TO“public.movie”)
)及(
任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.image”
||任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.plain text”
||任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.url”
||任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.movie”
||任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.text”)
).@计数<10
)@count==1

但这对我不起作用。在这种情况下如何使用。谢谢你的帮助

您不需要构建子查询。在扩展名的info.plist中,将显示NSExtension。它将使用NSExtension作为truepredicate。编辑该plist文件并添加NSExtensionActivationRule。相应地添加所需的密钥。有关键的详细信息


尝试使用此功能共享有限的图像、文档和视频

   SUBQUERY (
            extensionItems,
            $extensionItem,
            SUBQUERY (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.mpeg-4"
            ).@count == 0).@count == 1
            AND
            SUBQUERY (
            extensionItems,
            $extensionItem,
            SUBQUERY (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
            ).@count &lt;= 15).@count &gt;= 1
            AND
            SUBQUERY (
            extensionItems,
            $extensionItem,
            SUBQUERY (
            $extensionItem.attachments,
            $attachment,(
               ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.waveform-audio"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
            || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data"
            AND NOT ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
            )
            ).@count &lt;= 3
            ).@count == 1

这是我自己用的。这只允许1项,任何视频类型或任何图像类型。我修改了苹果公司的一个例子

为便于使用,请直接复制到plist:

SUBQUERY (extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ).@count == 1).@count == 1

你可以使用Parth Adroja的答案来分享基于特定计数的图像或视频。在我的例子中,扩展应该共享4个图像或1个视频,它们是互斥的

这就是我所做的

  • 第一个子查询选择最多4个计数的jpeg或png类型的图像,并检查所选视频的计数是否为零
  • 将OR条件添加到第一个子查询中,我们现在检查是否只选择了1个视频而没有选择任何图像
  • 添加第三个子查询以支持文本和web URL
  • NSExtensionActivationRule
    子查询(
    伸展岩,
    多边主义,
    (
    子查询(
    $m.attachments,
    $附件,
    任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.jpeg”||
    任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.png”
    )@count=4
    及
    子查询(
    $m.attachments,
    $附件,
    任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.movie”
    )@count==0
    )
    或
    (
    子查询(
    $m.attachments,
    $附件,
    任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.jpeg”||
    任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.png”
    )@count==0
    及
    子查询(
    $m.attachments,
    $附件,
    任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.movie”
    )@count==1
    )
    或
    (
    子查询(
    $m.attachments,
    $附件,
    任何$attachment.registeredTypeIdentifiers UTI-符合“public.text”或
    任何$attachment.registeredTypeIdentifiers UTI-符合“public.plain text”或
    任何$attachment.registeredTypeIdentifiers UTI-Compliance-TO“public.url”或
    )@count==1
    )
    )@count=1
    
    谢谢!,但我注意到TRUEPREDICATE只用于develope。如果应用程序包含字符串TRUEPREDICATE,则该应用程序将被拒绝@LạcBùi你是绝对正确的,但你可以更改我随附的屏幕截图中的值,请检查并相应应用。我使用过类似的plist文件。但我想确切地知道我的扩展不支持视频和图像。就像您同时点击选定的视频和图像一样,应用程序图标将消失。我刚刚更新了我的问题,很抱歉没有更新clear@Buvaty,可能您可以使用
    NSExtensionActivationDictionaryVersion
    nsextensionactivationsesstrictmatching
    SUBQUERY (extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ).@count == 1).@count == 1
    
    <key>NSExtensionActivationRule</key>
    <string>
        SUBQUERY (
          extensionItems,
          $extensionItem,
          (
            SUBQUERY (
              $extensionItem.attachments,
              $attachment,
              ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" ||
              ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"
            ).@count &lt;= 4
            AND
            SUBQUERY (
              $extensionItem.attachments,
              $attachment,
              ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
            ).@count == 0
          )
          OR
          (
            SUBQUERY (
              $extensionItem.attachments,
              $attachment,
              ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" ||
              ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"
            ).@count == 0
            AND
            SUBQUERY (
              $extensionItem.attachments,
              $attachment,
              ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
            ).@count == 1
          )
          OR
          (
            SUBQUERY (
             $extensionItem.attachments,
             $attachment,
               ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text" OR
               ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text" OR
               ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" OR
            ).@count == 1
          )
        ).@count &gt;= 1
    </string>