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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:54:40+00:00 2026-05-29T07:54:40+00:00

I’m making Catalog like iOS application. using Xcode 4.2 with story board. This application

  • 0

I’m making Catalog like iOS application. using Xcode 4.2 with story board.

This application have two views, and each changeable by tab bar controller.

Application image is here. http://www.0502.me/help/xcode-cat.png

I made Catalog view, and Table of Contents(TableView).
But I cannot change views from Table of Contents to Catalog view.

I think when Table of Contents’s page number value clicked, Catalog view’s variable and view change will be good result.

First View is Catalog view.
It’s controlled by FirstViewController, and for image scale change, PageView class also use.

Second view is table of contents, controlled by ListViewController. it’s parse plist(xml), and manipulate cell values(Title and Page number).

Code is below, please help.

FirstViewController
@implementation TableOfContentSecondViewController

    @synthesize currentPage;

    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Release any cached data, images, etc that aren't in use.
    }

    #pragma mark - View lifecycle

    -(void)pageLoad:(UIScrollView *)scrollView {

        currentPage = scrollView.contentOffset.x / scrollView.bounds.size.width;

        NSLog(@"CurrentPage- %i",currentPage);
        NSLog(@"CurrentOffSet- %f",scrollView.contentOffset.x);

        int pageWidth = self.view.frame.size.width;
        int pageHeight = self.view.frame.size.height;

        NSLog(@"pageWidth- %i",pageWidth);

        prevPage.frame = CGRectMake(
                                    pageWidth * (currentPage - 1), 
                                    0, 
                                    pageWidth, 
                                    pageHeight
                                    );

        if (currentPage > 0) {
            [prevPage setImage:[NSString stringWithFormat:@"%d", (currentPage - 1) % kPageNum]];
            prevPage.hidden = NO;
        }
        else {
            prevPage.hidden = YES;
        }

        currPage.frame = CGRectMake(
                                       pageWidth * currentPage, 
                                       0, 
                                       pageWidth, 
                                       pageHeight
                                       );

        [currPage setImage:[NSString stringWithFormat:@"%d", currentPage % kPageNum]];
        currPage.hidden = NO;

        nextPage.frame = CGRectMake(
                                    pageWidth * (currentPage + 1), 
                                    0, 
                                    pageWidth, 
                                    pageHeight
                                    );

        if(currentPage < (kPageNum -1)) {
            [nextPage setImage:[NSString stringWithFormat:@"%d", (currentPage + 1) % kPageNum]];

            nextPage.hidden = NO;
        }
        else {
            nextPage.hidden = YES;
        }
    }


    #pragma mark - View lifecycle

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.

        UIScrollView *scrollView = [[UIScrollView alloc] init];

        scrollView.frame = self.view.bounds;
        scrollView.contentSize = CGSizeMake(self.view.frame.size.width * kPageNum,
                                            self.view.frame.size.height
                                            );

        //NSLog(@"ContentSize- %@",NSStringFromCGSize(scrollView.contentSize));

        scrollView.pagingEnabled = YES;
        [self.view addSubview:scrollView];

        scrollView.delegate = self;

        prevPage = [[PageView alloc] initWithFrame:self.view.bounds];
        [scrollView addSubview:prevPage];

        currPage = [[PageView alloc] initWithFrame:self.view.bounds];
        [scrollView addSubview:currPage];

        nextPage = [[PageView alloc] initWithFrame:self.view.bounds];
        [scrollView addSubview:nextPage];

        [self pageLoad:scrollView];

    }

    -(void)scrollViewDidScroll:(UIScrollView *)scrollView {
        CGFloat position = scrollView.contentOffset.x / scrollView.bounds.size.width;

        CGFloat delta = position - (CGFloat)currentPage;

        if (fabs(delta) >= 1.0f) {
            [self pageLoad:scrollView];
        }

        //NSLog(@"ContentOffset- %f", scrollView.contentOffset.x);
    }

    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
        } else {
            return YES;
        }
    }

    @end

PageView.m
@implementation PageView

    - (id)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self) {
            // Initialization code
            imageView = [[UIImageView alloc] initWithFrame:self.bounds];
            [self addSubview:imageView];

            self.delegate = self;
            self.minimumZoomScale = 1.0;
            self.maximumZoomScale = 4.0;
        }
        return self;
    }

    -(void)adjustScrollView:(BOOL)animate {
        [self setZoomScale:self.minimumZoomScale animated:animate];
    }

    -(void)setImage:(NSString *)image {
        NSString *path = [[NSBundle mainBundle] pathForResource:image ofType:@"jpg"];

        NSLog(@"Image- %@",image);

        /*
        TableOfContentSecondViewController *tcController = [[TableOfContentSecondViewController alloc] init];
        tcController.currentPage = 120;
        */

        imageView.image = [UIImage imageWithContentsOfFile:path];

        [self adjustScrollView:NO];
    }

    -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
        return imageView;
    }

    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [touches anyObject];

        if([touch tapCount] > 1) {
            [self adjustScrollView:YES];
        }
    }


    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    - (void)drawRect:(CGRect)rect
    {
        // Drawing code
    }
    */

    @end

SecondViewController is for Table of Contents.
if there is no child element, bring back Page number.

ListViewController.m

    @implementation ListViewController

    @synthesize tableDataSource,currentTitle,currentLevel;


    - (id)initWithStyle:(UITableViewStyle)style
    {
        self = [super initWithStyle:style];
        if (self) {
            // Custom initialization
        }
        return self;
    }

    - (void)didReceiveMemoryWarning
    {
        // Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];

        // Release any cached data, images, etc that aren't in use.
    }

    #pragma mark - View lifecycle

    - (void)viewDidLoad
    {
        [super viewDidLoad];

        if(currentLevel == 0) {
            NSArray *tempArray = [[NSArray alloc] init];
            self.tableDataSource = tempArray;

            TableOfContentAppDelegate *AppDelegate = (TableOfContentAppDelegate *)[[UIApplication sharedApplication] delegate];
            self.tableDataSource = [AppDelegate.data objectForKey:@"Rows"];
            self.navigationItem.title = @"Table of Contents";
        }
        else
            self.navigationItem.title = currentTitle;

        // Uncomment the following line to preserve selection between presentations.
        // self.clearsSelectionOnViewWillAppear = NO;

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    }

    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }

    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
    }

    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    }

    - (void)viewWillDisappear:(BOOL)animated
    {
        [super viewWillDisappear:animated];
    }

    - (void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:animated];
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }

    #pragma mark - Table view data source

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    #warning Potentially incomplete method implementation.
        // Return the number of sections.
        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    #warning Incomplete method implementation.
        // Return the number of rows in the section.
        return [self.tableDataSource count];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
        NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
        cell.textLabel.text = [dictionary objectForKey:@"Title"];

        return cell;

        // Configure the cell...

        return cell;
    }



    #pragma mark - Table view delegate

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {

        NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];

        NSArray *Children = [dictionary objectForKey:@"Children"];

        if([Children count] == 0) {

            /* I want to Jump to selected page on scrollView */

        }
        else {
            ListViewController *rvController = [[ListViewController alloc] initWithStyle:UITableViewStylePlain];

            rvController.currentLevel += 1;

            rvController.currentTitle = [dictionary objectForKey:@"Title"];

            [self.navigationController pushViewController:rvController animated:YES];

            rvController.tableDataSource = Children;
        }

        // Navigation logic may go here. Create and push another view controller.
        /*
         <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
         // ...
         // Pass the selected object to the new view controller.
         [self.navigationController pushViewController:detailViewController animated:YES];
         */
    }

    @end        @implementation ListViewController

    @synthesize tableDataSource,currentTitle,currentLevel;


    - (id)initWithStyle:(UITableViewStyle)style
    {
        self = [super initWithStyle:style];
        if (self) {
            // Custom initialization
        }
        return self;
    }

    - (void)didReceiveMemoryWarning
    {
        // Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];

        // Release any cached data, images, etc that aren't in use.
    }

    #pragma mark - View lifecycle

    - (void)viewDidLoad
    {
        [super viewDidLoad];

        if(currentLevel == 0) {
            NSArray *tempArray = [[NSArray alloc] init];
            self.tableDataSource = tempArray;

            TableOfContentAppDelegate *AppDelegate = (TableOfContentAppDelegate *)[[UIApplication sharedApplication] delegate];
            self.tableDataSource = [AppDelegate.data objectForKey:@"Rows"];
            self.navigationItem.title = @"Table of Contens";
        }
        else
            self.navigationItem.title = currentTitle;

        // Uncomment the following line to preserve selection between presentations.
        // self.clearsSelectionOnViewWillAppear = NO;

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    }

    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }

    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
    }

    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    }

    - (void)viewWillDisappear:(BOOL)animated
    {
        [super viewWillDisappear:animated];
    }

    - (void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:animated];
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }

    #pragma mark - Table view data source

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    #warning Potentially incomplete method implementation.
        // Return the number of sections.
        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    #warning Incomplete method implementation.
        // Return the number of rows in the section.
        return [self.tableDataSource count];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
        NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
        cell.textLabel.text = [dictionary objectForKey:@"Title"];

        return cell;

        // Configure the cell...

        return cell;
    }



    #pragma mark - Table view delegate

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {

        NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];

        NSArray *Children = [dictionary objectForKey:@"Children"];

        if([Children count] == 0) {

            /* I want to Jump to selected page on scrollView */

        }
        else {
            ListViewController *rvController = [[ListViewController alloc] initWithStyle:UITableViewStylePlain];

            rvController.currentLevel += 1;

            rvController.currentTitle = [dictionary objectForKey:@"Title"];

            [self.navigationController pushViewController:rvController animated:YES];

            rvController.tableDataSource = Children;
        }

        // Navigation logic may go here. Create and push another view controller.
        /*
         <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
         // ...
         // Pass the selected object to the new view controller.
         [self.navigationController pushViewController:detailViewController animated:YES];
         */
    }

    @end
  • 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-29T07:54:41+00:00Added an answer on May 29, 2026 at 7:54 am

    Perhaps this will help:

    Coordinating Efforts Between View Controllers

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.