我正在嘗試爲我的iOS應用創建/導出獨有的UTI類型(與Instagram完全處理UTI com.instagram.exclusivegram非常相似)。獨家iOS UTI
基本上,我希望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>
只要你指定你的文件格式符合'public.png'或'public.jpeg'或類似的規定,他們可以打開這些UTI文件的所有應用程序將能夠打開它們。如果你刪除你的UTTypeConformsTo數組,那應該可以解決你的問題。 – Greg
換句話說,不要指定你的'com.photoapp.exclusive'符合'com.photoapp.photo'。保留'com.photoapp.photo'原樣,並且不要指定'com.photoapp.exclusive'的任何一致性。 – Greg
謝謝!你是否想要發表評論以便我能接受你的回答? – joshholat