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 9161485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:58:38+00:00 2026-06-17T13:58:38+00:00

What I m Thinking to do is ? there is one MainViewController in which

  • 0

What I m Thinking to do is ? there is one MainViewController in which there are two UIViews one loaded UITableViewController and other UIPageViewController.
In TableViewController, there are list of pdf’s names. But when i click of the pdf list, it does not loads the PageViewController with new pdf in context.

Pdf file names are store in .plist file, Pdfs are fetch from NSBundle or NSDocumentDirectory

In TableViewController

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath 
    {
        [tableView deselectRowAtIndexPath:indexPath animated:YES];    
        Play *play = (Play *)[[self.sectionInfoArray objectAtIndex:indexPath.section] play];
        Quotation *qute = [play.Details objectAtIndex:indexPath.row];
        if ([qute.Key isEqualToString:@"ABC"])
        {
            AppDelegate *app = [[UIApplication sharedApplication]delegate];
            app.strpdfname = qute.Value;
            MiddleViewController *mid = [[MiddleViewController alloc] initWithNibName:@"MiddleViewController" bundle:nil];
            ContentViewController *cvc = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];
            [mid viewDidLoad];
            [cvc viewDidLoad];
        }
        else
        {
            MainViewController *vc = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
            [vc viewDidLoad];
        }
    }

In PageViewController
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        self.modelArray = [[NSMutableArray alloc] init];

        AppDelegate *app = [[UIApplication sharedApplication] delegate];
        self.pdfName = app.strpdfname;

        NSString *path = [[NSBundle mainBundle] pathForResource:pdfName ofType:nil];
        NSURL *targetURL = [NSURL fileURLWithPath:path];

        originalPDF = CGPDFDocumentCreateWithURL((__bridge CFURLRef)targetURL);
        numberOfPages = CGPDFDocumentGetNumberOfPages(originalPDF);

        for (int index = 0; index < numberOfPages ; index++)
        {
            [self.modelArray addObject:[NSString stringWithFormat:@"%d",index]];
        }

        self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl                                               navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
        self.pageViewController.delegate = self;
        self.pageViewController.dataSource = self;
        contentViewController = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];
        contentViewController.labelContents = [self.modelArray objectAtIndex:0];
        NSArray *viewControllers = [NSArray arrayWithObject:contentViewController];
        [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward
                                       animated:NO 
                                     completion:nil];
        [self addChildViewController:self.pageViewController];
        [self.view addSubview:self.pageViewController.view];
        [self.pageViewController didMoveToParentViewController:self];       
        CGRect pageViewRect = self.view.frame;
        pageViewRect = CGRectInset(pageViewRect, 0.0, 0.0);
        self.pageViewController.view.frame = pageViewRect;
        self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;
    }

    - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController 
      viewControllerBeforeViewController:(UIViewController *)viewController
    {
        NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)viewController labelContents]];
        if(currentIndex == 0)
        {
            return nil;
        }
        contentViewController = [[ContentViewController alloc] init];
        contentViewController.labelContents = [self.modelArray objectAtIndex:currentIndex - 1];
        return contentViewController;
    }

    - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
       viewControllerAfterViewController:(UIViewController *)viewController
    {
        NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)viewController labelContents]];
        if(currentIndex == self.modelArray.count-1)
        {
            return nil;
        }
        contentViewController = [[ContentViewController alloc] init];
        contentViewController.labelContents = [self.modelArray objectAtIndex:currentIndex + 1];
        return contentViewController;
    }

    - (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController
                   spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation
    {
        UIViewController *currentViewController =   [self.pageViewController.viewControllers objectAtIndex:0];
        NSArray *viewControllers = [NSArray arrayWithObject:currentViewController];
        [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];
        self.pageViewController.doubleSided = NO;
        return UIPageViewControllerSpineLocationMin;
    }

In ContentViewController of PageViewController
    -(UIImage*) imageFromPDF:(CGPDFDocumentRef)pdf withPageNumber:(NSUInteger)pageNumber withScale:(CGFloat)scale
    {
        CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdf,pageNumber);
        CGRect tmpRect = CGPDFPageGetBoxRect(pdfPage,kCGPDFMediaBox);
        CGRect rect =   CGRectMake(tmpRect.origin.x,tmpRect.origin.y,tmpRect.size.width*scale,tmpRect.size.height*scale);
        UIGraphicsBeginImageContext(rect.size);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextTranslateCTM(context,-50,rect.size.height-30);
        CGContextScaleCTM(context,scale,-scale);
        CGContextDrawPDFPage(context,pdfPage);
        UIImage* pdfImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return pdfImage;
    }

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        AppDelegate *app = [[UIApplication sharedApplication] delegate];
        self.pdfName = app.strpdfname;
        i = [labelContents intValue];    
        NSString *path = [[NSBundle mainBundle] pathForResource:pdfName ofType:nil];
        if (i!=0)
        {
            CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((__bridge CFURLRef)[NSURL fileURLWithPath:path]);
            UIImage *img = [[UIImage alloc] init];
            img = [self imageFromPDF:pdf withPageNumber:i withScale:1];
            UIImageView *imgview1 = [[UIImageView alloc] initWithImage:img];
            [self.view addSubview:imgview1];
        }
        else 
        {
            UIImage *imgmain = [UIImage imageNamed:@"Diary4.png"];
            UIImageView *imgvmain = [[UIImageView alloc] initWithImage:imgmain];
            imgvmain.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y,580,self.view.frame.size.height);
            [self.view addSubview:imgvmain];
        }   
    }

In MainViewController

-(void)viewDidload
    {
        leftView = [[UIView alloc] initWithFrame:CGRectMake(5,25, 200,715)];
        leftView.backgroundColor = [UIColor clearColor];    
        tvc = [[TableViewController alloc] initWithStyle:UITableViewStylePlain];
        tvc.plays = self.plays;
        tvc.view.frame = leftView.frame;
        leftView.clipsToBounds = YES;
        [leftView addSubview:tvc.view];
        [self.view addSubview:leftView];
        middleView = [[UIView alloc] initWithFrame:CGRectMake(107, 30, 575, 670)];
        mvc = [[MiddleViewController alloc] initWithNibName:@"MiddleViewController" bundle:nil];
        [mvc.view setFrame:middleView.frame];
        [middleView addSubview:mvc.view];
        [self.view addSubview:middleView];
    }
  • 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-06-17T13:58:39+00:00Added an answer on June 17, 2026 at 1:58 pm

    As there is no reload data method for UIPageViewController. I was using UIPageViewController in UIViewController instead of that I use UINavigationController in which the UIPageViewController can be reloaded with dynamic data.So on click of UITableViewController, data is sends to UINavigationController–>UIPageViewController. This has solved the above issue.

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

Sidebar

Related Questions

Ok so this one is strange and I'm thinking there must be a problem
Is there any elegant way of splitting a list/dict into two lists/dicts in python,
I have two points, one is always at the origin (0,0), and the other
Am I right in thinking that there's only ONE icon included in google maps,
I'm doing PHP development and I'm thinking of using one of these. I have
This might seem as silly question but I am thinking there might be the
I'm thinking if there's a way (a component or reference) to breakdown an adodb.recordlist
I'm thinking if there is a way to use javascript to pick up ANY
I was thinking if there's a better solution for adding onclick handler to each
I've been thinking for a while if there's a way to get cross-domain AJAX

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.