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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:44:58+00:00 2026-05-25T23:44:58+00:00

When I create a uiviewcontroller from the new file… wizard with create xib file

  • 0

When I create a uiviewcontroller from the “new file…” wizard with “create xib file” option, I can load it by just SomeViewController *view = [[SomeViewController alloc] init]. But when I rename the xib file name, this code stops working, even though the file owner in the xib is still the right view controller.

I found that I can only get the view up by calling initWithNib. I am just wondering what was linking the xib with the view controller behind the scene? Can I still use init to get the xib loaded after renaming the file?

Regards

Leo

  • 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-25T23:44:58+00:00Added an answer on May 25, 2026 at 11:44 pm

    I can load it by just SomeViewController *view = [[SomeViewController alloc] init].

    You can, but (IMO) you shouldn’t. The designated initializer for UIViewController is -initWithNibName:bundle:. You might implement an -init method in your own view controller that calls [super initWithNibName:nil bundle:nil], but I think the code is clearer if you stick with the same name.

    Also, make sure you read the documentation for UIViewController, particularly the discussion, which says:

    If you specify nil for the nibName parameter, you must either override
    the loadView method and create your views there or you must provide a
    nib file in your bundle whose name (without the .nib extension)
    matches the name of your view controller class.

    This is why the view controller will load a .xib file that has the same name as the view controller’s class (or the name returned by the -nibName method, as explaind a little further on in the docs).

    In short, UIViewController is functioning exactly as documented.

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

Sidebar

Related Questions

1. Step: Create a new UIViewController: - Xcode -> New File... -> Cocoa Touch
Here is what I do: 1) Create New UIViewController subclass , tick with NIB
Summary From a conceptual point of view, should one be working with UIViewController subclasses
In my UIViewController's initWithNibNameOrNil , I call: locationManager = [CLLocationManager new]; to create the
I have written a subclass of UIViewController which creates a view programmatically, instead of
Create a flat text file in c++ around 50 - 100 MB with the
Create a file called Valid[File].txt and stick some text in it. Start powershell and
Create a new appdomain, setup the assemblyResolve handler and you always get an exception
I have been wondering which is the best way to load a navigation view.
In a UIViewController subclass I create a bar button item that fires an event

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.