मैं एक अलग ऐप में एक फ़ाइल कैसे भेजूं यह जानकर कि कौन सा यूटीआई ऐप का समर्थन करता है? आइए कहें कि फ़ाइल में कोई फ़ाइल एक्सटेंशन नहीं है, लेकिन मुझे फ़ाइल के यूटीआई को पता है।UIDocumentInteractionController, कोई फ़ाइल एक्सटेंशन नहीं लेकिन यूटीआई
मैं निम्नलिखित की कोशिश की:
// target is a NSURL with the location of the extension less file on the system
// knownUTI is a NSString containing the UTI of the file
UIDocumentInteractionController* dic = [UIDocumentInteractionController interactionControllerWithURL:target];
[dic retain];
dic.delegate = self;
dic.UTI = knownUTI;
[dic presentOpenInMenuFromRect:CGRectZero inView:superController.view animated:YES]
यह समर्थित अनुप्रयोग से पता चलता है, तथापि, अगर मैं उसका चयन करें, यह ऐप स्विच नहीं होंगे। प्रतिनिधि
- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application
लेकिन
- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application
कभी नहीं कहा जाता है कॉल करता है और आवेदन कभी नहीं स्विचन है।
लक्ष्य अनुप्रयोग निम्नलिखित में अपनी यूटीआई का निर्यात करता है:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>Migration DocType</string>
<key>CFBundleTypeRol</key>
<string>Shell</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.mycomp.customstring</string>
</array>
</dict>
</array>
...
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>My custom UTI</string>
<key>UTTypeIdentifier</key>
<string>com.mycomp.customstring</string>
</dict>
</array>
इस के रूप में काम नहीं किया, मैं भी एक कस्टम एक्सटेंशन जोड़ की कोशिश की। फिर भी, यह इस तरह से काम नहीं करेगा। फ़ाइल में कस्टम एक्सटेंशन जोड़ते समय मैं DocumentInteractionController
पर सौंपता हूं और यह काम करता है। हालांकि, अनुप्रयोगों की सूची यूटीआई प्रकार I आपूर्ति के बावजूद एक ही फ़ाइल एक्सटेंशन का समर्थन करने वाले सभी अन्य अनुप्रयोगों को दिखाती है।
मैं 2 अलग अनुप्रयोगों में 2 यूटीआई घोषित कहते हैं:
App1 with UTI1: com.mycomp.a with extension .abc
App2 with UTI2: com.mycomp.b with extension .abc
जब DocumentInteractionController करने के लिए फ़ाइल सौंपने, और com.mycomp.a
लिए यूटीआई की स्थापना यह भी फ़ाइल को संभालने के लिए सक्षम किया जा रहा एक संभव आवेदन के रूप में App2 दिखाएगा ।
मैं निम्नलिखित तरीके से विस्तार के साथ एक यूटीआई परिभाषित:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>My UTI Type</string>
<key>UTTypeIdentifier</key>
<string>com.mycomp.a</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>abc</string>
<key>public.mime-type</key>
<string>application/abc</string>
</dict>
</dict>
</array>
मैं आपकी मदद वास्तव में सराहना करेंगे, मैं एक तरह से अटक कर रहा हूँ। तो, फिर से सवाल: मैं बिना किसी एक्सटेंशन के ज्ञात यूटीआई के साथ एक ऐप में एक फाइल कैसे भेजूं या अन्य फाइलों के समान एक्सटेंशन रखूं, जिनमें से मैं दस्तावेज़ इंटरेक्शन कंट्रोलर में पसंद के रूप में एप्लिकेशन नहीं दिखाना चाहता हूं?
धन्यवाद
मुझे एक आसान समाधान मिला। 'WillBeginSendingToAplication:' से कोड को खुले मेनू में सफलतापूर्वक बुलाए जाने के बाद पहले ही निष्पादित किया जा सकता है, इससे विधियों को तेज करने की आवश्यकता समाप्त हो जाती है! – Jan
कृपया इसके लिए कोड प्रदान करें। मैंने नाम संपत्ति सेट करने का प्रयास किया है लेकिन यह तृतीय पक्ष ऐप में प्रतिबिंबित नहीं होता है। – slott
हां, * असली * समाधान का एक विस्तृत लेखन सबसे उपयोगी होगा। – buildsucceeded