I've implemented the UIDocumentInteractionController in an iPad application - the purpose is to open documents fetched from a networked location and display them.
Looking online, I've got this far:
-(void)viewDidLoad
{
[super viewDidLoad];
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"test.docx"];
NSLog(@"Path is %@", filePath);
docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
docController.delegate = self;
[docController presentPreviewAnimated:YES];
}
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *)controller
{
return self;
}
- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
return self.view;
}
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
return self.view.frame;
}
Whilst this works, or at least doesn't crash, I just get an animated 'Loading' screen. The document is incredibly small and as you can see from the code sample, located in the project, so shouldn't really take any time at all to load.
Where am I going wrong?