iOS Share扩展如何支持* .wav文件 [英] iOS Share extension how to support *.wav files

查看:323
本文介绍了iOS Share扩展如何支持* .wav文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所述,我希望我的扩展程序在用户共享* .wav文件时显示

As the title states, I want my extension to show up when the users share *.wav files

我遇到了以下苹果文档:
https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW8

I've come across the following apple documentation: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW8

我正在试图弄清楚如何实际使用文档中提到的内容来做到这一点。文档让我觉得我有最多的感觉,如果不是我需要的所有部分,而不是他们如何一起去。

I'm trying to figure out how to actually use what is mentioned in the documentation to do so. The documentation leaves me with the feeling I have most if not all the pieces I need, but not how they go together.

我明白我很可能不得不建立一个SUBQUERY(..)声明,但它在哪里?我如何使用它?

I understand that I'll most probably have to build a "SUBQUERY(..)" statement, but where does it go? How do I use it?

推荐答案

我最终做了以下事情:

对于NSExtensionActivationRule键,我将类型从Dictionary更改为String并输入以下字符串(您可以保留格式,不需要全部内联):

for the NSExtensionActivationRule key, I changed the type from Dictionary to String and entered the following string (you can keep the formatting, doesn't need to be all inline):

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

您只需要:

ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio"

但我的扩展程序也支持电影和图像,这就是为什么它也有这些(留给那些可能很好奇如何支持多个。请注意,我决定支持更多的音频选项而不仅仅是波浪,因为我最初在询问。可以在此处查找类型:统一类型标识符参考

but my extension also supports movies and images which is why it has those too (left it in for those that may be curious how to support more than one. Note that I've decided to support more audio options than just waves as I was initially inquiring about. The types can be looked up here: Uniform Type Identifiers Reference

第一次计数检查确保主机应用程序中的每个选定项目都符合扩展名。

The first count check makes sure that every single selected item in the host app conforms with the extension.

第二次计数检查,最后一次用于表示扩展程序接受1个或多个项目(符合)。如果您只想允许您的分机处理1件商品,请输入以下内容:

The second count check, the one at the end is used to indicate that the extension accepts 1 or more items (that conform). If you wanted to only allow for 1 item at the time to be processed by your extension you would enter the following:

).@count == 1

或者,如果您想允许多个具有上限的项目:

or, if you wanted to allow for multiple items with an upper limit:

).@count < 4

).@count <= 3

这篇关于iOS Share扩展如何支持* .wav文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆