简体   繁体   English

特定文件格式的 iOS 8 共享扩展

[英]iOS 8 Share Extension for specific file format

Let's say I have a .gif file.假设我有一个 .gif 文件。 When I select it and click Share, I want to see my app in App Extension sheet, but ONLY if it has ".gif" filename extension.当我选择它并单击共享时,我想在应用程序扩展表中看到我的应用程序,但前提是它具有“.gif”文件扩展名。 How can I achieve that?我怎样才能做到这一点?

See Apple docs at App Extension Programming about NSExtensionActivationRule . 请参阅App Extension Programming上有关NSExtensionActivationRule Apple文档。

Basically you need to supply a predicate string for it that excludes any files that don't comply. 基本上,您需要为其提供谓词字符串,以排除任何不符合要求的文件。 (This will be easy if there is a UTType for .gif, as there is for .PNG ( kUTTypePNG ), but I'm not sure that there is) (如果存在.gif的UTType ,就像.PNG( kUTTypePNG )那样,这将很容易,但是我不确定是否存在)

Second thing to try would be to reject on filename (if that is possible) else you'll have to accept all kUTTypeImage and reject in the extension itself. 要尝试的第二件事是拒绝文件名(如果可能的话),否则您将必须接受所有kUTTypeImage并拒绝扩展名本身。

I don't think accepting all shares that comply with kUTTypeImage but rejecting any that comply with kUTTypeJPEG and kUTTypePNG would work as a solution, as apps might provide images in several formats, including .gif. 我不认为接受所有符合kUTTypeImage但拒绝任何符合kUTTypeJPEGkUTTypePNG将作为解决方案,因为应用程序可能会提供多种格式的图像,包括.gif。

What if you have a complex predicate statement as a filter and you want to filter OUT GIFs.如果您有一个复杂的谓词语句作为过滤器,并且您想过滤掉 GIF,该怎么办? More specifically, what if i wanted to filter out by a files extension (of unknown type to the OS).更具体地说,如果我想通过文件扩展名(操作系统未知类型)过滤掉该怎么办。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM