Reputation: 289
I am trying to open PDF file into my application with a custom UIBarButtonItem
into the UINavigationBar
, two options to open pdf into IOS
-UIDocumentInteractionController
-QLPreviewController
in IOS6
i have found this posts with prove that we cant customize the UINavigationBar
Custom navigationItem button with QLPreviewController in iOS6
QLPreviewController remove or add UIBarButtonItems
http://www.cimgf.com/2012/07/11/a-better-fullscreen-asset-viewer-with-quicklook/
Custom "Email" action in UIDocumentInteractionController
"iOS6
Update This technique of overriding the QLPreviewController
will no longer work in iOS 6
. I have contacted Apple about the situation, but they simply stated that it is no longer supported and it is considered a private API"
is there is any other way to open PDF in IOS
without Using UIWebView
and to customize the UIBarButtonItem
.
Upvotes: 0
Views: 313
Reputation: 1585
I don't know what exactly you want to do with the PDF, but you can open a PDF file from the bundle using some code like this:
CGPDFDocumentRef pdfDoc;
CGPDFPageRef pdfPage;
NSURL* pdfURL = [[NSBundle mainBundle] URLForResource:@"filename" withExtension:@"pdf"];
CFURLRef urlRef = (__bridge CFURLRef)pdfURL;
pdfDoc = CGPDFDocumentCreateWithURL(urlRef);
if (pdfDoc == NULL) {
// Not good
}
if (CGPDFDocumentIsEncrypted (pdfDoc)) {
if (!CGPDFDocumentUnlockWithPassword (pdfDoc, "")) {
if (!CGPDFDocumentUnlockWithPassword (pdfDoc, "password")) {
// Not good, document is locked
}
}
}
if (!CGPDFDocumentIsUnlocked (pdfDoc)) {
CGPDFDocumentRelease(pdfDoc);
} else {
pdfPage = CGPDFDocumentGetPage(pdfDoc, 1);
CGPDFPageRetain(pdfPage);
// ...
}
From this point on the documentations from Apple should help you:
Core Graphics Framework Reference
Upvotes: 1