Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-10-2010, 12:56 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 26
borg359 is on a distinguished road
Default Opening a pdf without an extension in iBooks

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 {
	
}
borg359 is offline   Reply With Quote
Reply

Bookmarks

Tags
extension, ibooks, launch, open, pdf

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 350
10 members and 340 guests
7twenty7, chiataytuday, condor304, Creativ, Domele, dreamdash3, laureix68, LEARN2MAKE, mistergreen2011, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,661
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, tinamm64
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:28 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0