0
votes

It's a weird problem, there are many different type files on my list such as pdf, ppt, xls etc, everything works fine with them but some doc files are not displaying.

I use WebView, UIDocumentInteractionController, QLPreviewController to display the files but I have the same problem. Like this

enter image description here

When I use webview I have this screen

enter image description here

The files size are OK, i mean not too big and there is no problem while opening in computer. I tested the app in a real device, same problem..

Here is the similar problem and i think that there is a bug in ios as they said

How to manage memory within a QLPreviewController

But I believe that there should be a solution, is it a memory problem? I use Xamarin.iOS and this is my code

QLPreviewItemBundle prevItem = new QLPreviewItemBundle(info.FileName, info.FilePath);
QLPreviewController previewController = new QLPreviewController();
previewController.DataSource = new PreviewControllerDS(prevItem);
NavigationController.PushViewController(previewController, true);

and this is for UIDocumentInteractionController

var documentPath = docInfo.FilePath;
UIDocumentInteractionController interationController  = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(documentPath));

interationController.Name = docInfo.FileName;
interationController.ViewControllerForPreview = (controller) => NavigationController;
interationController.DidEndPreview += (sender, e) =>
{
 interationController.Dispose(); interationController = null;
};

InvokeOnMainThread(() => interationController.PresentPreview(true));
1

1 Answers

1
votes

Try using this method,

 -(void)loadDocument:(NSString*)documentName inView:(UIWebView*)webView
    {
        NSString *path = [[NSBundle mainBundle] pathForResource:documentName ofType:nil];
        NSURL *url = [NSURL fileURLWithPath:path];
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        [webView loadRequest:request];
    }

    // Calling -loadDocument:inView:
    [self loadDocument:@"mydocument.rtfd.zip" inView:self.myWebview];