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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:57:42+00:00 2026-06-09T05:57:42+00:00

I have 1 view controller acting as a CustomViewContainer and it has 2 child

  • 0

I have 1 view controller acting as a CustomViewContainer and it has 2 child view controllers with only 1 added initially at launch.

Invoking addChildViewController from the Container on the child and then a subsequent invoke of didMoveToParentViewController on the child doesn’t display my child view on the screen. Instead, I still see the parent controller’s view.

@implementation ContainerViewController // inherits from UIViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    LOG_METHOD_SIG();    
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
    {
        // ChildViewController is a subclass of UIViewController
        _childController = [[ChildViewController alloc] initWithNibName:nil bundle:nil];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self addChildViewController:_childController];

    // Expected the following line to display the child controller's view
    [_childController didMoveToParentViewController:self];
}

If I add [self.view addSubview:_childController.view] after 'addChildViewController', the view is shown. But I thought that the whole point of container view controllers was to avoid direct view manipulation.

In the case where you’re adding your first child view controller, could you call ‘transitionFromViewController` and if so, what would be the ‘from’ view controller?

  • 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-09T05:57:43+00:00Added an answer on June 9, 2026 at 5:57 am

    addChildViewController does just that: it adds a child view controller. It does nothing with its view. transitionFromViewController:toViewController:duration:options:animation:completion (or whatever…) is where the magic happens. Your fromViewController could be the view controller you added initially, the toViewController is your second view controller.

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

Sidebar

Related Questions

I have two view controller classes in my application delegate. I can change from
I have a view controller class that has to implement several protocols. Too keep
I have a view controller (derived from UIViewController not UITableViewController) containing a table view.
I have a view controller that can fetch many different types of entities from
A have a view controller, and it creates a downloader object, which has a
I have standard view controller acting as the delegate for a modal view controller
I have a view controller called searchUpdateController , it has a button to push
I have one view controller in which I have added UIScrollView & UIImageView programatically.
I have a view controller that is used to populate data from the core
I have a view controller who's views are loaded from a nib file. The

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.