iOS 8 股分机。如何使图像成为必需但文本可选
iOS 8 share extension. How to make an image a requirement but text optional
我希望我的共享扩展仅在共享图像时显示。如果正在共享文本和图像,它也应该显示出来。
我有
NSExtensionActivationSupportsText = 1
NSExtensionActivationSupportsImageWithMaxCount = 1
但是如果只有文本,那么共享小部件仍然会出现。必须有共享的图像才能使我的扩展工作。
您可以使用 "Declaring Supported Data Types for a Share or Action Extension" 下解释的谓词语句。
可以找到有关谓词语法的更多信息here。
我想你想使用这样的东西:
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
OR ( ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text"
AND ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image")
).@count >= 1
).@count == 1
只需将 NSExtensionActivationRule 添加到您的 NSExtensionAttributes 字典中。将类型设置为字符串,并将值设置为上面的 SUBQUERY。
我希望我的共享扩展仅在共享图像时显示。如果正在共享文本和图像,它也应该显示出来。
我有
NSExtensionActivationSupportsText = 1
NSExtensionActivationSupportsImageWithMaxCount = 1
但是如果只有文本,那么共享小部件仍然会出现。必须有共享的图像才能使我的扩展工作。
您可以使用 "Declaring Supported Data Types for a Share or Action Extension" 下解释的谓词语句。
可以找到有关谓词语法的更多信息here。
我想你想使用这样的东西:
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
OR ( ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text"
AND ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image")
).@count >= 1
).@count == 1
只需将 NSExtensionActivationRule 添加到您的 NSExtensionAttributes 字典中。将类型设置为字符串,并将值设置为上面的 SUBQUERY。