I am trying to load files in device by using UIDocumentInteractionController in a phonegap app. I have done by following.
#import <Foundation/Foundation.h>
#import <QuickLook/QuickLook.h>
@interface FileViewer : UIViewController <UIDocumentInteractionControllerDelegate>
@end
@implementation FileViewer
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (UIViewController *) documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller {
return self;
}
- (void)viewDidLoad
{
[self viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
In Launcher.m i have done by following to show files:
CDVViewController* mainController = (CDVViewController*)[ super viewController ];
UIDocumentInteractionController *documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:fileLocation]];
FileViewer *vController = [[FileViewer alloc]init];
[mainController addChildViewController:vController];
documentInteractionController.delegate = vController;
[documentInteractionController presentPreviewAnimated:YES];
This result by giving error message: "Presenting view controllers on detached view controllers is discouraged. Unbalanced calls to begin/end appearance transitions for QLRemotePreviewContentController"
Thanks in advance!!