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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:51:02+00:00 2026-05-26T10:51:02+00:00

Is the initWithNibName always called whenever programmatically or IB? Example: I have two viewController,

  • 0

Is the initWithNibName always called whenever programmatically or IB?

Example:

I have two viewController, one named PhotoViewController, the other named ViewController.
The PhotoViewController creates view programmatically, but with initWithNibName uncommented.

Here is my PhotoViewController.m:

- (void)loadView
{
    NSLog(@"loadView in PhotoView");
    UIView *view = [[UIView alloc] initWithFrame:[UIScreen 
                                                  mainScreen].applicationFrame]; 
    [view setBackgroundColor:[UIColor redColor]]; 
    self.view = view; 
    [view release]; 
}

// Loading views from a nib file.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    NSLog(@"PhotoViewController initWithNibName=%@",nibNameOrNil);
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

Here is my call in ViewController.m

- (void) doSearchFlickr
{
    PhotoViewController *pController  = [[PhotoViewController alloc]init];
    [self.view addSubview:pController.view];
    [pController release];
}

Then I see something confusing me in the log:

2011-10-23 10:52:52.151 TableViewPG[1192:b303] PhotoViewController initWithNibName=(null)
2011-10-23 10:52:52.153 TableViewPG[1192:b303] loadView in PhotoView

According to the ViewControllerPGforiPhoneOS on page 30, if I override loadView programmatically, initWithNibName should not be called.

Is there any flaw(s) in my logic?

  • 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-26T10:51:03+00:00Added an answer on May 26, 2026 at 10:51 am

    -[UIViewController init] just executes [self initWithNibName:nil bundle:nil]. You can easily check this by putting a breakpoint in your -[PhotoViewController initWithNibName:bundle:] and looking at the call stack.

    Your -[PhotoViewController loadView] is fine.

    The View Controller Programming Guide for iOS doesn’t say anything about initWithNibName:bundle: on page 30.

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

Sidebar

Related Questions

I have some view controllers: StockTwitsTVViewController* stvViewController = [[[StockTwitsTVViewController alloc] initWithNibName:@StockTwitsTVViewController bundle:nil]autorelease]; UINavigationController *stvNavController
FlipView *fl=[[FlipView alloc] initWithNibName:@FlipView bundle:nil]; //fl.view.frame=CGRectMake(50.0,50.0, 300.0,300.0); fl.delegate=self; fl.modalTransitionStyle=UIModalTransitionStyleCrossDissolve; fl.imageName=aCategoryDtl.Tip_Image; [self presentModalViewController:fl animated:YES]; In
In -(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil parentController:(GameViewController *)myGameController{ Have a series of transforming labels like
here's my code: ViewController *vc = [[ViewController alloc] initWithNibName:@TableView bundle:nil]; [self.navigationController presentModalViewController:vc animated:YES]; //[self
I have a navigation controller with a table view. In most tutorials I've read
The code: UIViewController *viewController = [[UIViewController alloc] initWithNibName:@NibName bundle:nil]; UINavigationController *navigationController = [[UINavigationController alloc]
I have been using UIViewController s and initWithNibName with much success, basically using them
I have a view controller: @interface DetailViewController : UIViewController It displays a map and
I'm recoding a splitview controller app I did so the table view isn't always
-(void)Save{ MainScreenContoller *main= [[MainScreenContoller alloc] initWithNibName:@MainScreenContoller bundle:nil]; [self.view.superview addSubview:[main view]]; } This is 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.