gpt4 book ai didi

iphone - 独家 iOS UTI

转载 作者:可可西里 更新时间:2023-11-01 03:13:39 28 4
gpt4 key购买 nike

我正在尝试为我的 iOS 应用创建/导出一个独有的 UTI 类型(非常类似于 Instagram 独占处理 UTI com.instagram.exclusivegram 的方式)。

基本上,我希望 com.photoapp.photo 成为应用程序可以使用的内容,如果他们希望能够在任何注册拍照的应用程序中打开照片(类似于 Instagram 的 com.instagram.photo)。然后我希望 com.photoapp.exclusive 只能在我的应用程序中打开(类似于 com.instagram.exclusivegram)。

我在我的设备上遇到的问题是,即使在使用 com.photoapp.exclusive 时,UIDocumentController 也会提示我在 PhotoApp 或 DropBox 中打开它,而它应该只是 PhotoApp。

我有一个注册 UTI 的应用程序以及一个用于检查打开能力的示例应用程序。我在示例应用程序中使用的代码如下:

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"photoapp://"]]) {
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"derp.png"], 1.0);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *fullPathToFile = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"photoapp.pae"];
[imageData writeToFile:fullPathToFile atomically:NO];

interactionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"file://%@", fullPathToFile]]];
interactionController.UTI = @"com.photoapp.exclusive";
interactionController.delegate = self;

[interactionController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
}

这是我的应用程序的 plist 文件中的内容:

<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeDescription</key>
<string>Exclusive PhotoApp Photo</string>
<key>UTTypeConformsTo</key>
<array>
<string>com.photoapp.photo</string>
</array>
<key>UTTypeIdentifier</key>
<string>com.photoapp.exclusive</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>pae</string>
</dict>
</dict>
<dict>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>pa</string>
</dict>
<key>UTTypeIdentifier</key>
<string>com.photoapp.photo</string>
<key>UTTypeDescription</key>
<string>PhotoApp Photo</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.png</string>
<string>public.jpeg</string>
</array>
</dict>
</array>
<key>UIFileSharingEnabled</key>
<true/>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>LSItemContentTypes</key>
<array>
<string>com.photoapp.exclusive</string>
<string>com.photoapp.photo</string>
</array>
<key>CFBundleTypeName</key>
<string>Photo</string>
<key>LSHandlerRank</key>
<string>Default</string>
</dict>
</array>

最佳答案

一旦您指定了 UTI,例如 public.pngpublic.jpeg,所有指定可以打开这些类型文件的应用程序都将能够打开你的文件。因此,如果您根本没有在 com.photoapp.exclusive UTI 中指定任何类型一致性,则似乎没有任何应用支持它。

关于iphone - 独家 iOS UTI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12769494/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com