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

  • Home
  • SEARCH
  • 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 8771917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:54:39+00:00 2026-06-13T17:54:39+00:00

This puzzles me to no end. Say you do: [self.view addSubview: someController.view]; How does

  • 0

This puzzles me to no end.

Say you do:

[self.view addSubview: someController.view];

How does someController knows that it’s view is being loaded and call viewDidAppear, etc.?

What we are passing is it’s view and not the controller. Yet someController knows.

Also what happen if self.view itself is not in the window’s view Hierarchy. Will someController’s viewWillAppear, etc. be called?

One way to implement this is to have the view to have a weak pointer to the controller, say as it’s delegate, and then check if the view itself is a descendant of the window object.

Is this the way it’s actually implemented? If not, how it’s actually done? Even if it’s not, is it correct to think that it’s implemented that way?

My concern is the following:
I am curious because I want to understand how this viewWillAppear show up. Months I played with IOS calling those explicitly not knowing why it’s called or not called. There are tons of posts complaining about viewWillAppear/Disapear get called or not called. Some get called twice. I want to know exactly how and when it’s called. I am getting good at it but not quite there yet.

  • 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-13T17:54:40+00:00Added an answer on June 13, 2026 at 5:54 pm

    I’ve never seen the UIKit source code, but I’m certain it is as you suspect, and that UIView has a private reference to the UIViewController. This is confirmed by the documentation for UIResponder. Since both UIView and UIViewController participate in the responder chain, you can get a reference to the controller from the view by calling the view’s nextResponder method (emphasis mine):

    The UIResponder class does not store or set the next responder automatically, instead returning nil by default. Subclasses must override this method to set the next responder. UIView implements this method by returning the UIViewController object that manages it (if it has one) or its superview (if it doesn’t); UIViewController implements the method by returning its view’s superview; UIWindow returns the application object, and UIApplication returns nil.

    As for your other question: I don’t think viewWillAppear: will be called unless the view is actually going to appear; in other words, not unless the view is in the window’s view hierarchy. (You could easily write a quick demo project to test this.)

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

Sidebar

Related Questions

I have this algorithm that I found here, just one thing puzzles me about
This question relates to those parts of the KenKen Latin Square puzzles which ask
Let's say I want to find all sets of 5 single-digit, non-repeating numbers that
I have a little method that does some CoreGraphics drawing. Today I was using
I have a Client and ProposalRequest model that look like this: class Client <
I have this mysql query that I am trying to analyze. It is very
I have a managed c++ dll with few managed classes that in turn call
I'm writing a class for solving sudoku puzzles that has some two dimensional arrays
Hy, I would like to ask a question that puzzles me. I've a class
I recently ran across this puzzle, was finally able to struggle out a hacky

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.