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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:26:56+00:00 2026-06-02T23:26:56+00:00

I’m pretty new to iOS, and am attempting to present a view controller from

  • 0

I’m pretty new to iOS, and am attempting to present a view controller from within another view controller as described here:

Stack overflow answer (see third answer)

and also here on Apple’s site

I start with the Hello World Example code. I open up MyViewController.m and modify the updateString() method, adding this code to the end:

{
        // Get the application's "window"
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
        // Get the window's rootViewController (NOTE: Only works on iOS 4.0 or later!)
    UIViewController *rootViewController = window.rootViewController;

        // Create our new controller
    UIViewController *enterNameController = [[UIViewController alloc] initWithNibName:@"HighScore" bundle:[NSBundle mainBundle]];

    if (enterNameController != NULL)
    {
        printf("\nLoaded UIView controller. Installing as actionSheetController...\n\n");

        UINavigationController *navigationController = [[UINavigationController alloc]
                         initWithRootViewController:enterNameController];

            // Present out Enter Name for High Score view as a modal view
    //  [rootViewController presentViewController:navigationController animated:YES];       // iOS 2.0 and newer
        [self presentViewController:navigationController animated:YES completion: nil];     // iOS 5.0 and newer
    }
}

I have also created a NIB file called “HighScore.xib” that I put with the other NIB files that came with the HelloWorld, and I also added HighScore.xib to the XCode project, and dragged it into the “Copy Bundle Resources” section.

As-is, I get an error when running and entering text into the edit field:

* Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Could not load NIB in bundle: ‘NSBundle (loaded)’ with name ‘HighScore”

However if I change the final statement to use “rootViewController” instead of “self” then nothing happens. No exception, but no new view is presented either.

Questions:

1) Why won’t my NIB load? I’m obviously doing something wrong here.

2) Why does using “rootViewController” instead of “self” produce different results? Shouldn’t the rootViewController find the same class as “self”?

Note that when using “rootViewController” I get a warning in XCode: “MyViewController’ may not respond to ‘-presentViewController:animated:completion”

  • 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-02T23:26:57+00:00Added an answer on June 2, 2026 at 11:26 pm

    I solved this problem by:

    a) Using the tutorial here:

    http://timneill.net/2010/09/modal-view-controller-example-part-1/

    b) Right-clicking and doing “Get Info” on the .xib file in the XCode project, and modifying its Type to be “file.xib” instead of “sourcecode.xib”. Without this second change, it would not load! Bizarre. But this was ultimately the problem!!

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

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.