我有几个像这样的NSStrings:
@property (nonatomic, copy, readonly) NSString *browserName;
@property (nonatomic, copy, readonly) NSString *browserVersion;
@property (nonatomic, copy, readonly) NSString *browserMajor;
@property (nonatomic, copy, readonly) NSString *operatingSystemName;
我如何使用UIDocumentInteractionController获取这些字符串并创建可以共享,发送电子邮件,复制等文档
我已经在我的应用程序中显示了文档控制器,我只是不知道如何使用这些字符串中的信息填充文件。
如果您需要更多详细信息或有疑问,请与我们联系
答案 0 :(得分:0)
我是这样做的:
NSArray *visitorInfoArray = [NSArray arrayWithObjects:@"Visitor Location", _visitor.location, @"currentURL", _visitor.currentURL, nil];
NSString *visitorInfo = [visitorInfoArray componentsJoinedByString:@" "];
NSString *filename = @"User Info";
NSURL *tempURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:filename]];
[visitorInfo writeToURL:tempURL atomically:YES encoding:NSUTF8StringEncoding error:nil];
[MTq main:^{
[FCIProgress dismiss];
DLog(@"%@", visitorInfo);
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:tempURL];
self.documentInteractionController.UTI = @"public.plain-text";
[self.documentInteractionController presentOptionsMenuFromBarButtonItem:sender animated:YES];
}];