Hi guys,
I've been able to successfully send a pdf file from my application bundle to iBooks using the code below. Now I'm trying to extend this in order to open pdf files that do not have the .pdf extension. It seems that iBooks is unable to determine the type of this file, even though I'm manually telling it that the file's UTI = "com.adobe.pdf", which is the UTI that it automagically assigns pdf files with extensions.
Does anyone have any experience with making iBooks open files without extensions?
Here's the code that works when it comes to opening pdf files with proper extensions. The iBookAction method is meant to be the target of a button in your view. The proceeding three methods are the required delegates to make the iBook launch work.
Code:
- (void)iBookAction {
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString * documentsDir = [paths objectAtIndex:0];
NSString * PDFArXivePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"pdf"];
NSLog(@"Loading Archive file at path =%@", PDFArXivePath);
docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:PDFArXivePath2]];
docController.delegate = self;
[docController retain];
docController.UTI = @"com.adobe.pdf";
NSLog(@"UTI = %@", docController.UTI);
// Present an Open in menu for the default application with which to open the file
[docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}
- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application {
}
- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application {
}
- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller {
}