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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:04:11+00:00 2026-06-09T08:04:11+00:00

I have a button that open another viewController (familyView) when clicked. In familyView there

  • 0

I have a button that open another viewController(familyView) when clicked.
In familyView there is another button which suppose to bring me back to the mainViewController(ViewController.xib) but I don’t know how to call the main viewController.

My method to call familyView

UIViewController* familyView = [[UIViewController alloc] initWithNibName:@"familyView" bundle:[NSBundle mainBundle]];
[self.view addSubview:familyView.view];

I hope you could help on how to call the main ViewController ? do I have to use the same method to call it? like this I mean:

UIViewController* mainView = [[UIViewController alloc] initWithNibName:@"viewController" bundle:[NSBundle mainBundle]];
[self.view addSubview:mainView.view];

If yes, is there a better way to implement this? in my demo project, I’m trying to make 7 views full with data and a button to go back and forth.

EDIT:
If I use UIView would that be best for me instead of using different viewControllers with their implementations and interfaces files?
My project will have views, and each view has data on it parsed from a different html page.

  • 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-09T08:04:14+00:00Added an answer on June 9, 2026 at 8:04 am

    There are two method that can be used.

    1. UINavigationController
    2. Delegates

    From your question it seems that a UINavigationController is the best option but I will show you both.


    UINavigationController

    When you load your mainViewController from your app delegate your going to need to wrap it in a nav controller like so:

    AppDelegate.h

    @property (strong, nonatomic) UINavigationController *navController;
    

    AppDelegate.m

    @synthesize navController = _navController;
    

    //in didFinishLaunchingWithOptions:

    UIViewController *mainViewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
    
    navController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
    
    self.window.rootViewController = nav1;
    [self.window makeKeyAndVisible];
    

    Now in your MainViewController you have the convince of UINavigationController.

    When you want to push to a child from a parent you can simply do:

    ChildViewController *child = [[ChildViewController alloc]...];
    [self.navigationController pushViewController:child animated:YES];
    

    If you in your ChildViewController and want to go back simply do:

    [self.navigationController popViewControllerAnimated:YES];
    

    This is the “Drill Down” technique.

    (I know “Drill Down” has more meaning than simply that but it provides a good frame of reference.)


    Delegate

    Now the other method that you have is to setup delegates between the classes. So if your in childView and need to call your parent, you will have a channel to do so.

    In your MainViewController.h setup it like so:

    #import <UIKit/UIKit.h>
    
    //This is our delegate
    @protocol TalkToParentDelegate <NSObject>
    
    //This is our delegate method
    - (void)helloParent;
    @end
    
    @interface MainViewController : UIViewController <TalkToParentDelegate> 
    ...
    ..
    @end
    

    In your MainViewController.m make sure add the delegate method.

    - (void)helloParent {
      NSLog(@"Hello child, let me do something here");
    }
    

    In your ChildViewController.h setup it like so:

    #import <UIKit/UIKit.h>
    
    //Add header of class where protocol was defined
    #import "MainViewController.h"
    
    @interface ChildViewController : UIViewController
    
    //Create a property we can set to reference back to our parent
    @property (strong, nonatomic) id <TalkToParentDelegate> delegate;
    
    @end
    

    Now, in your MainViewController.m , whenever you present your ChildViewController do this:

    ChildViewController *child = [[ChildViewController alloc]...];
    
    //Set the delegate reference to parent 
    child.delegate = self;
    
    //present the view
    

    Last but not least, no when you in your child you can call methods on your parent (MainViewController) like so:

    [self.delegate helloParent];


    So here are two methods that you can use.

    I would like to note however, you can use these together. Say you had a UINavigationController but still needed a child to talk to its parent, you can setup a delegate so that’s possible.

    • Hope this helps.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I have is button that should open another page only if textbox length
I have written a Java program that should open another program (which is a
I have a button that when clicked will run a stored procedure on a
I have a button that opens a dialog when clicked. The dialog displays a
I have a main dialog and on that dialog there is a button. When
I have some code that uses a form.submit() to open up another window when
I have a button which on clicking opens jquery dialog. Inside that jquery dialog
I have two nib files, one that will open at startup and another that
I have a button which redirects the user to another page. Instead, I would
So I have these buttons in my app that I want to open .PDF

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.