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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:42:31+00:00 2026-06-14T10:42:31+00:00

Consider a UIViewController whose view contains the view of another UIViewController . Is it

  • 0

Consider a UIViewController whose view contains the view of another UIViewController.

Is it correct to say that the parent UIViewController is responsible to call the lifecycle methods of the child controller? Methods such as:

- (void)viewWillAppear:(BOOL)animated;
- (void)viewDidAppear:(BOOL)animated;
- (void)viewWillDisappear:(BOOL)animated;
- (void)viewDidDisappear:(BOOL)animated;

For example:

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

If so, which methods must be called?

Is there a better way to do this? Clearly the above approach is not forward-compatible: if a new lifecycle method is added the parent class needs to be modified to propagate the call of the new method.

Or is nesting view controllers simply a bad idea and should be avoided?

  • 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-14T10:42:33+00:00Added an answer on June 14, 2026 at 10:42 am

    The correct way to do this is to add the view controller as a child view controller. You need to maintain both a view hierarchy (adding the view as a subview) and a view controller hierarchy (adding the view controller as a child). All of the life cycle methods are then called for you.

    The relevant methods are addChildViewController: and didMoveToParentViewController:.

    There was a talk on view controller containment in WWDC 2011, I recommend watching the video.

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

Sidebar

Related Questions

I created an UITabbarController that its first item is an UIViewController, this UIViewController contains
Consider the following code: public interface A { public A another(); } public interface
Consider an ASP.NET Web API service that redirects public class ThisController : ApiController {
Consider the following scenario: I have a page that can open a dialog (jquery
Consider this example - I have a class called Report that has a field
Consider the following code in the initialiser of a class: UIViewController* blankViewController=[[DisplayViewController alloc] initWithNibName:@Blank
Consider this problem: I have a program which should fetch (let's say) 100 records
Consider that we are given an isometric grid (consider something like Diablo) of tiles.
Consider an article inside a div that has many <p> tag. Is there any
Consider this scenario. We have an internal Rails 2 app that connects to a

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.