小编dam*_*net的帖子

文件共享/在另一个应用程序中发送文件(在iOS中"打开")

我的应用程序创建一个名为log.txt的简单文件

此文件的URL(在xcode中查看)是file:// localhost/var/mobile/Applications/NUMBER OF THE APPLICATION /Documents/log.txt

所以我可以在finder中看到这个文件......

我想在我的应用程序中添加"打开"功能,以便用户共享此文件(通过邮件或imessage)或在另一个兼容的应用程序中打开此文件.

这是我做的:

-(void) openDocumentIn {

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:docFile]; //docFile is the path
//NSLog(@"%@",fileURL); // -> shows the URL in the xcode log window

UIDocumentInteractionController *documentController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
documentController.delegate = self;
documentController.UTI = @"public.text";
[documentController presentOpenInMenuFromRect:CGRectZero
                                       inView:self.view
                                     animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

然后调用这个函数:

-(IBAction)share:(id)sender {
    [self openDocumentIn];
}
Run Code Online (Sandbox Code Playgroud)

当我运行应用程序时,我点击这个"共享"按钮,但除了在日志窗口中显示URL的路径之外没有任何附加内容...

我错过了什么......

谢谢

编辑:最后,它适用于我真正的iPhone ...模拟器中没有文本查看器! - "

编辑2:它显示可用的应用程序(页面,碰撞......)但最终崩溃:(((见这里的崩溃图片

iphone xcode share file ios

10
推荐指数
2
解决办法
7547
查看次数

当NSURLConnection时,swift UIActivityIndi​​catorView

我知道如何动画UIActivityIndi​​catorView我知道如何建立连接 NSURLConnection.sendSynchronousRequest

但我不知道如何动画UIActivityIndi​​catorView WHILE与之建立联系 NSURLConnection.sendSynchronousRequest

谢谢

nsurlconnection uiactivityindicatorview ios swift

5
推荐指数
1
解决办法
6449
查看次数