标签: uidocumentinteraction

UIDocumentInteractionController在退出时崩溃

我的主菜单上有一个常规的UIButton,它当前启动了一个UIViewController; 相应的.m文件的内容如下:

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    documentPath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"pdf"];
    NSURL *targetURL = [NSURL fileURLWithPath:documentPath];

    document = [UIDocumentInteractionController interactionControllerWithURL: targetURL];
    document.delegate = self;
    [document retain];

    return self;
}

-(UIViewController *)documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
    return self;
}

-(void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
    [document autorelease];
}

-(void)viewDidLoad
{
    [super viewDidLoad];

    [document presentPreviewAnimated: YES]; // ** CRASH **
}

-(void)viewDidUnload
{
    [super viewDidUnload];
}

-(void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

-(void)dealloc
{ …
Run Code Online (Sandbox Code Playgroud)

iphone uiviewcontroller ios uidocumentinteraction

6
推荐指数
1
解决办法
5981
查看次数

注册所有文件类型(CFBundleDocumentTypes)

Drop Box或Airsharing等程序不处理或编辑文档,而是存储它们.在这种情况下,似乎他们必须注册为任何类型的文件的有效选择.有没有办法将您的应用程序注册为所有文件的处理程序?'.*'?或者是注册您能想到的任何类型文件的唯一解决方案?

iphone uidocumentinteraction

6
推荐指数
1
解决办法
3722
查看次数

在iOS 4.3模拟器上断开的DocInteraction示例代码(UIDocumentInteractionController)

Apple提供的DocInteraction示例代码位于http://developer.apple.com/library/ios/#samplecode/DocInteraction/Introduction/Intro.html (下载地址:http://developer.apple.com/library/ios/在4.3上模拟时,samplecode/DocInteraction/DocInteraction.zip)不起作用.它在4.2上工作正常.我看了看但没有收到任何错误或任何警告.不确定发生了什么.以为我会问这里.我已经报了.它只是加载一个白色的屏幕.

有任何想法吗?

iphone ipad ios uidocumentinteraction

6
推荐指数
1
解决办法
1万
查看次数

使用QuickLook框架或UiDocumentInteractionController显示加密文件

我在本地存储了加密的word/excel/pdf文件,我需要在我的iPad应用程序中预览.我知道QLPreviewController或UiDocumentInteractionController可用于预览这些文件.我很好用这个

- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index {

    return [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[documents objectAtIndex:index] ofType:nil]];
}
Run Code Online (Sandbox Code Playgroud)

但是文件是加密的,当我解密它时,我会得到NSData对象.我如何在其中任何一个中加载NSData.

另外我理解我可以很好地将NSData存储为本地文件并将其加载到预览中.但是存在不在本地存储未加密文件的限制.

如果某人已经完成了这项工作并且可以帮助我,我们将不胜感激.

谢谢AJ

iphone quicklook ipad ios uidocumentinteraction

6
推荐指数
1
解决办法
4460
查看次数

在QLPreviewController中配置底栏

我在我的应用程序中集成了QLPreviewController和UIDocumentInteractionController,它运行正常.

唯一的问题是 - 我想配置底部工具栏,我想删除默认工具栏项,如下图所示:

底部工具栏,带有要移除的物品

有什么办法可以这样做,请建议.

uitoolbar qlpreviewcontroller uidocumentinteraction ios6 ios7

6
推荐指数
1
解决办法
1680
查看次数

文档交互控制器与iOS 7状态栏?

UIDocumentInteractionController似乎有麻烦特别是在横向的新的iOS 7的状态栏正确交互.我现在用于显示查看器的代码:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"example" ofType:@"pdf"];
    NSURL *url = [NSURL fileURLWithPath:filePath];

    UIDocumentInteractionController *pdfViewer = [UIDocumentInteractionController interactionControllerWithURL:url];
    [pdfViewer setDelegate:self];
    [pdfViewer presentPreviewAnimated:YES];
}

- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
    return self;
}

- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
    return self.view;
}
Run Code Online (Sandbox Code Playgroud)

当交互控制器首次出现时,状态栏与标题重叠.

在此输入图像描述

在另一侧旋转到横向可以暂时修复该行为.

在此输入图像描述

正如预期的那样,点击文档本身可以解散框架.然而,一旦再次轻敲文档以激活帧,则与第一图像一样再次发生重叠.

我试过设置documentInteractionControllerRectForPreview无济于事.

- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
    return CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height);
}
Run Code Online (Sandbox Code Playgroud)

我不希望在交互控制器启动时隐藏状态栏,我认为可以正确执行此操作,因为Mail应用程序行为正常并且看起来它使用的是同一个类.

为任何想要使用代码的人附加的最小示例项目:https: //hostr.co/PiluL1VSToVt

cocoa-touch statusbar ios uidocumentinteraction ios7

6
推荐指数
1
解决办法
3760
查看次数

UIDocumentInteractionController不显示邮件选项

继承我的应用程序中的UIDocuemtnInteractionController(不显示邮件选项) 在此输入图像描述

这是Apples示例项目使用的那个 在此输入图像描述

以下是各自的代码

我的应用程序

docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
[docInteractionController presentOpenInMenuFromBarButtonItem:(UIBarButtonItem*)sender animated:YES];
Run Code Online (Sandbox Code Playgroud)

Apple示例项目

NSURL *fileURL;
if (cellIndexPath.section == 0)
{
    // for section 0, we preview the docs built into our app
    fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:documents[cellIndexPath.row] ofType:nil]];
}
else
{
    // for secton 1, we preview the docs found in the Documents folder
    fileURL = [self.documentURLs objectAtIndex:cellIndexPath.row];
}
self.docInteractionController.URL = fileURL;

[self.docInteractionController presentOptionsMenuFromRect:longPressGesture.view.frame
                                                   inView:longPressGesture.view
                                                 animated:YES];
Run Code Online (Sandbox Code Playgroud)

我应该怎样做才能获得邮件选项?

ios uidocumentinteraction ios7

6
推荐指数
1
解决办法
6260
查看次数

无法解除从iOS 8中的UIDocumentInteractionController调用的电子表格

我有一个非常简单的测试应用程序,其中只包含以下代码,附加到UIButton:

- (IBAction)buttonUp:(id)sender {

  // Build file path
  NSString* filePath = [[NSBundle mainBundle] pathForResource:@"testfile"
                                                       ofType:@"txt"];

  NSURL *url = [NSURL fileURLWithPath:filePath];

  m_interactionController = [UIDocumentInteractionController interactionControllerWithURL:url];

  [m_interactionController presentOptionsMenuFromRect:CGRectMake(200, 200, 100, 100)
                                               inView:[self view]
                                             animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

这构建没有问题,并在iOS 7(在第4代iPad:A1458)下运行,这个代码工作正常.

问题是,在iOS 8 Beta 5中,如果用户从中选择"邮件" UIDocumentInteractionController,则显示的电子邮件表永远不会被删除.点击发送确实发送邮件,但电子表格继续显示.点击取消并选择删除或保存草稿无效.

使用Xcode 5.1.1构建测试应用程序时会出现此问题.但是,如果应用程序是使用Xcode 6 GM构建的,则不会出现问题,并且代码工作正常.

上面的代码有什么问题吗?

cocoa-touch ios uidocumentinteraction ios7 ios8

6
推荐指数
1
解决办法
682
查看次数

iOS Swift使用URL下载和打开文件

在我的应用中,我正在打开文件下载。一切都做得很完美,但是问题是zip,rar,tar文件等文件正在下载,但下载完成后这些文件将不会显示。这是我尝试的代码:

func DownloadDocumnt()
    {
        let sucessAlert = UIAlertController(title: "Download Files", message: "Download the file \(self.TopLbl.text!) to your mobile for offline access.", preferredStyle: UIAlertControllerStyle.alert)

        sucessAlert.addAction(UIAlertAction(title: "Start Download", style: UIAlertActionStyle.default, handler:  { action in

            self.view.makeToastActivity(message: "Downloading...")
            let fileURL = URL(string: "\(self.DocumentURL)")!
            let documentsUrl:URL =  FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first as URL!
            let destinationFileUrl = documentsUrl.appendingPathComponent("\(self.TopLbl.text!)")
            let sessionConfig = URLSessionConfiguration.default
            let session = URLSession(configuration: sessionConfig)
            let request = URLRequest(url:fileURL)
            let task = session.downloadTask(with: request) { (tempLocalUrl, response, error) in
                if let tempLocalUrl = tempLocalUrl, …
Run Code Online (Sandbox Code Playgroud)

zip rar nsfilemanager uidocumentinteraction swift3

6
推荐指数
1
解决办法
3426
查看次数

旋转后UIDocumentInteractionController消失

我用来UIDocumentInteractionController与设备上的其他应用共享数据

 self.docInteraction = [UIDocumentInteractionController interactionControllerWithURL:imageAttachFile];
 self.docInteraction.delegate = self;
 [self.docInteraction presentOpenInMenuFromRect:CGRectZero inView: self.view animated: YES ];
Run Code Online (Sandbox Code Playgroud)

它工作得很好,但它在设备旋转后消失了.它的原因是什么以及如何解决这个问题?

objective-c ios uidocumentinteraction

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