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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:35:45+00:00 2026-05-12T14:35:45+00:00

Have patience with me, I’m still learning Cocoa Touch. Other -viewDidLoad not being called

  • 0

Have patience with me, I’m still learning Cocoa Touch. Other -viewDidLoad not being called question was unrelated to my issue, I did search.

I have FooViewController, a UIViewController subclass. FooViewController.xib has its File’s Owner set to FooViewController. Additionally, I have Main, whose App Delegate is MyApplication and whose File’s Owner is UIApplication. My primary nib is set to Main.

I am able to make the view appear on the screen, using this flow (code snipped for brevity):

UIWindow *main;

-(void)applicationDidFinishLaunching:(UIApplication*)application {
    [self showFooViewController];
    [main makeKeyAndVisible];
}

-(void)showFooViewController {
    fooViewController = [[FooViewController alloc] init];
    if(![[NSBundle mainBundle] loadNibNamed:@"FooViewController" owner:fooViewController options:nil]) {
        DebugF(@"Failed to load FooViewController");
        return;
    }

    // Add the view and put it in place
    UIView *view = [fooViewController view];
    CGRect cur = [view frame];
    cur.origin = CGPointMake(0.0f, 20.0f);
    [view setFrame:cur];

    [main addSubview:[fooViewController view]];
}

However, this message is not being sent to FooViewController:

- (void) viewDidLoad {
    DebugF(@"Hello!");
}

Total silence in gdb’s output.

I’ve seen other Cocoa tutorials that show Instances and such in IB’s document view, but I do not see these options in mine. Am I supposed to be instantiating fooViewController in the Nib? Did I miss a connection? In FooViewController.xib, File’s Owner view is connected to the view in the Nib.

I’m sure this is a simple solution, and I have wandered down the wrong path. Halp!

  • 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-12T14:35:46+00:00Added an answer on May 12, 2026 at 2:35 pm

    I have not found documentation to back up the following, but this is what I’ve deduced by experiment / experience:

    The viewDidLoad method is expected be called immediately after loadView is called, and it’s up to whomever calls loadView to supply the extra call to viewDidLoad.

    In some cases, the SDK will handle this behavior for you. Suppose you have a subclass of UIViewController called MyViewController; then:

    • If you access myViewController.view before you call loadView, then the superclass accessor is smart enough to call loadView for you, and viewDidLoad immediately thereafter.

    As a result, if your code looks like this:

    MyViewController *myViewController = [[MyViewController alloc] init];
    [superView addSubview:myViewController.view];  // Calls viewDidLoad.
    

    then both loadView and viewDidLoad will be called on your behalf.

    However, if your code looks like this:

    MyViewController *myViewController = [[MyViewController alloc] init];
    [myViewController loadView];
    [superView addSubview:myViewController.view];  // Doesn't call viewDidLoad.
    

    then the view getter can see you’ve already loaded the view, and it assumes you also called viewDidLoad as well – so it doesn’t call either. Ironically, the extra function call here prevents viewDidLoad from getting called.

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

Sidebar

Related Questions

I'm an impulsive coder by nature and have started learning the virtue of patience
Have you ever tried learning a language while on a project? I have, and
have not tested on windows. but in ubuntu when u disconnect from the network,
First try with ajax, please have patience. <html> <script type=text/javascript src=jquery-1.4.2.min.js></script> <script type=text/javascript> $(document).ready(function()
I have run into a EclipseLink issue with multiple queries running against the DB
I have a very basic question how the creation of HTTPSession works.I know you
I'm a complete beginner in JS, so pls have patience :) my.hello = function
I have done a fair amount of reading on this and I am not
I'm quite new to C# and encryption so please have patience with me. I
I hope someone has the patience to look at this..... I have a flash

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.