Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6844201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:20:48+00:00 2026-05-27T00:20:48+00:00

Hi I am recently work with Leaves api and I have problem with this

  • 0

Hi I am recently work with Leaves api and I have problem with this , I need to display a PDF file , and my ViewController class has a nib file , I implement the code base on API sample code but does not show anything ! Am I missing something ?

#import "BookViewController.h"
#import "Utilities.h"

@implementation BookViewController



/////EDITED//////////////


- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    if (self = [super initWithNibName:@"BookViewController" bundle:nil]) {

        CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("paper.pdf"), NULL, NULL);
        pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
        CFRelease(pdfURL);

    }
    return self;
}





- (void)dealloc {
    CGPDFDocumentRelease(pdf);
    [super dealloc];
}



- (void) displayPageNumber:(NSUInteger)pageNumber {
    self.navigationItem.title = [NSString stringWithFormat:
                                 @"Page %u of %u", 
                                 pageNumber, 
                                 CGPDFDocumentGetNumberOfPages(pdf)];
}



#pragma mark  LeavesViewDelegate methods

- (void) leavesView:(LeavesView *)leavesView willTurnToPageAtIndex:(NSUInteger)pageIndex {
    [self displayPageNumber:pageIndex + 1];
}



#pragma mark LeavesViewDataSource methods

- (NSUInteger) numberOfPagesInLeavesView:(LeavesView*)leavesView {
    return CGPDFDocumentGetNumberOfPages(pdf);
}

- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx {
    CGPDFPageRef page = CGPDFDocumentGetPage(pdf, index + 1);
    CGAffineTransform transform = aspectFit(CGPDFPageGetBoxRect(page, kCGPDFMediaBox),
                                            CGContextGetClipBoundingBox(ctx));
    CGContextConcatCTM(ctx, transform);
    CGContextDrawPDFPage(ctx, page);
}


#pragma mark UIViewController

- (void) viewDidLoad {
    [super viewDidLoad];
    leavesView.backgroundRendering = YES;
    [self displayPageNumber:1];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:20:49+00:00Added an answer on May 27, 2026 at 12:20 am

    How are you instantiating your controller?

    If you call initWithNibName (as I suppose you do, since you say it has a nib file), you are totally skipping your local init method (i.e., the one in BookController); therefore, the PDF handling is not initialized at all.

    Try renaming your init method to initWithNibName, and it should work; or create an initWithNibName and make it call you init (google for “designated constructor” to learn more about this pattern).

    Notice that the full signature of initWithNibName is:

    - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle
    

    You have more options available, like creating the controller by calling init (instead of initWithNibName) or even create a method setPDF, then, after you create the controller any way you like, you can call this method, which in turns calls initialize, etc…

    EDIT: if you decide to instantiate manually the controller, don’t forget to define loadView:

    - (void)loadView {
        [super loadView];
        if (leavesView) {
            leavesView.frame = self.view.bounds;
            leavesView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
            [self.view addSubview:leavesView];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

An application I have recently started work on has to register two dll's, because
I have recently started work on a project that has already been running for
I have recently started work at a company that has a website. The previous
I found this little gem in our codebase at work recently. I have to
I have recently started work on a large project in .net (C#) and I
I have been doing tons of Ajax recently and work with lots of my
I recently tried to work out how the solution to a ThreadPool class works
I have recently started work on an application that is already deployed to production.
I'd like to know whether something like this has been done before: I've recently
I've been a PHP developer but recently need to work on some project using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.