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

  • SEARCH
  • Home
  • 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 6884567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:31:31+00:00 2026-05-27T05:31:31+00:00

I am attempting to drill down through a number of UITableViewControllers , eventually getting

  • 0

I am attempting to drill down through a number of UITableViewControllers, eventually getting to a pdf file which is loaded based on what section and row the user selects. I am attempting to pass the section and row information to the PDFViewController (which works), but I am not able to pass the selected section and row information to a UIScrollView, which actually loads the PDF. I attempted to set a property when the PDFScrollView is instantiated, but that value is not being retained when the PDFScrollView is loaded.

Code from PDFViewController.m

#import "PDFViewController.h"
#import "PDFScrollView.h"
#import "ProtocolDetailViewController.h"

@implementation PDFViewController

@synthesize detailIndexRow;
@synthesize detailIndexSection;


- (void)loadView {
    [super loadView];
// Log to check to see if detailIndexSection has correct value
NSLog(@"pdfVC section %d", detailIndexSection);
NSLog(@"pdfVc row %d", detailIndexRow);

// Create PDFScrollView and add it to the view controller.
    PDFScrollView *sv = [[PDFScrollView alloc] initWithFrame:[[self view] bounds]];
    sv.pdfIndexSection = detailIndexSection;

   [[self view] addSubview:sv];

}

Now from PDFScrollView.m where pdfIndexSection does not retain the value assigned to it in the above code from detailIndexSection

#import "PDFScrollView.h"
#import "TiledPDFView.h"
#import "PDFViewController.h"
#import <QuartzCore/QuartzCore.h>

@implementation PDFScrollView

@synthesize pdfIndexRow;
@synthesize pdfIndexSection;




- (id)initWithFrame:(CGRect)frame
{
// Check to see value of pdfIndexSection
NSLog(@"PDF section says %d", pdfIndexSection);
NSLog(@"PDF row says %d", pdfIndexRow);

 if ((pdfIndexSection == 0) && (pdfIndexRow == 0)) {

            NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"cardiacarrestgen.pdf" withExtension:nil];
            pdf = CGPDFDocumentCreateWithURL((__bridge_retained CFURLRef)pdfURL);
    }
    else if ((pdfIndexSection == 0) && (pdfIndexRow == 1)) {

            NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"cardiacarrestspec.pdf" withExtension:nil];
            pdf = CGPDFDocumentCreateWithURL((__bridge_retained CFURLRef)pdfURL);

    }

pdfIndexSection and pdfIndexRow are both int and return 0 no matter what section or row is selected in didSelectRowAtIndexPath.

So two questions:

  • Why when I assign an int value to sv.pdfIndexSection in the ViewController, does it not retain the value in the ScrollView.

  • Is there a better way to implement this concept?

  • 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-27T05:31:32+00:00Added an answer on May 27, 2026 at 5:31 am

    The problem is that in PDFScrollView you are accessing the fields pdfIndexSection and pdfIndexRow right in the initWithFrame method, but you are only setting their values after you call it.

    In other words, your - (id)initWithFrame:(CGRect)frame in PDFScrollView should be rewritten as

    // PDFScrollView
    -(id)initWithFrame:(CGRect)frame 
    pdfIndexRow:(int) pdfindexRow 
    pdfIndexSection:(int)pdfIndexSection
    

    and then in your PDFViewController you initialize it like

    PDFScrollView *sv = [[PDFScrollView alloc] initWithFrame:[[self view] bounds] 
    pdfIndexRow:detailIndexRow 
    pdfIndexSection:detailIndexSection ];
    

    The difference is that now you are passing the values in the init method, because you use them there. Another approach would be not to do the PDF loading logic in the initWithFrame method, but instead in a separate method. That way, you could keep initWithFrame simple, and have time to properly initialize any other fields you may had, before loading the PDF.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to build an interface and generics based graph and getting an odd error
When attempting to call functions in math.h , I'm getting link errors like the
I'm quite new to objective-j and the framework so I was attempting to drill
Attempting to generics-ify some legacy code, I'm stuck. I have a ParentObject which wraps
Attempting to run a MIB based SNMP script and I running into an issue.
Attempting to build a Visual Studio 2010 solution with 132 projects which do not
Attempting to create an itemgroup for use in a target where the file types
Attempting to use asp.net mvc's Action Result of File. So it would seem that
Attempting to move an uploaded file so that it is saved in the directory,
Attempting to learn CI and going through the docs to get a better understanding.

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.