Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to share a text string by UIDocumentInteractionController

Tags:

text

ios

share

we can use UIDocumentInteractionController to share a file to other apps like this:

    NSURL *url = [NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource: @"test.txt" ofType: nil]];
UIDocumentInteractionController *dic = [[UIDocumentInteractionController interactionControllerWithURL: url] retain];
[dic presentOpenInMenuFromRect: CGRectZero inView: self.view animated: YES];

but how to share a text string(not a text file) by UIDocumentInteractionController? Android Device can do this.

Thanks.

like image 209
Michael Avatar asked Mar 22 '26 05:03

Michael


1 Answers

You can't, UIDocumentInteractionController is for documents. It is even in the name.

A solution would be to save the string to text file and share that file, or if you want to share a string, for example to post on a social network you should use UIActivityViewController

like image 173
rckoenes Avatar answered Mar 24 '26 17:03

rckoenes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!