आपके पास UIActivityViewController पर बहुत सीमित नियंत्रण है, लेकिन यदि आप अच्छी तरह से ज्ञात माइम प्रकारों को जोड़ रहे हैं, तो मैंने पाया कि आप फ़ाइल फ़ाइल में संबंधित फ़ाइल एक्सटेंशन प्रदान करके इसे सही तरीके से काम करने के लिए प्राप्त कर सकते हैं। सोच क्यों अपनी फ़ाइलें ड्रॉपबॉक्स और अन्य सामान्य फ़ाइल की तरह क्षुधा को UIActivityViewController का उपयोग कर साझा नहीं किया जा रहा है
NSString *docsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
// The file extension is important so that some mime magic happens!
NSString *filePath = [docsPath stringByAppendingPathComponent:@"vcard.vcf"];
NSURL *fileUrl = [NSURL fileURLWithPath:filePath];
[data writeToURL:fileUrl atomically:YES]; // save the file
// Now pass the file URL in the activity items array
UIActivityViewController *avc = [[UIActivityViewController alloc] initWithActivityItems:
@[@"Here's an attached vCard", fileUrl] applicationActivities:nil];
[vc presentModalViewController:avc animated:YES];
यह वास्तव में काम करता है, धन्यवाद मार्किव :) मैंने इसे एक ऐप के लिए कस्टम फाइलें बनाने के लिए एक और गाइड के साथ संयुक्त किया (उदाहरण के लिए .myApp का उपयोग कर फाइलें), और उसे fileURL के साथ काम करने के लिए मिला। – Setomidor
इस पुराने प्रश्न को लाने के लिए खेद है, लेकिन '[डेटा लिखना नहीं चाहिए: फ़ाइलपैथ परमाणु रूप से: हाँ] '' [डेटा लिखें ToURL: fileURL परमाणु रूप से: हाँ] '? –
@ गैब्रिएल पेट्रोनेला हां या मेरा मानना है [डेटा लिखना टोफाइल: फ़ाइलपैथ परमाणु रूप से: हाँ] भी काम करेगा। –