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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:06:56+00:00 2026-05-28T20:06:56+00:00

I was trying to modally present a UINavigationController with a UITableViewController as it’s root

  • 0

I was trying to modally present a UINavigationController with a UITableViewController as it’s root view but kept crashing the app when pressing the button to present the modal view.

- (IBAction)flipToDefaultsViewController:(id)sender
{

    RootTableViewController *controller = [[RootTableViewController alloc] initWithNibName:@"RootTableViewController" bundle:nil];

    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:controller];
    nc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

    [self presentModalViewController:nc animated:YES];
}

The app crash with the message:

[RootTableViewController numberOfSectionsInTableView:]: message sent to deallocated instance 0x5677b5

When I loaded up Instruments to take a further look it was apparent that two instances of my UITableViewController were created, one with the owner of the UINavigationController and the other by UIKit. The UIKit created instance was the one that was deallocated and causing the crash.

When I changed the initialisation from initWithNibName:bundle: to init the UITableViewController loaded fine (my .xib file was the same name as the class).

My question is why would this happen?

Should you not initialise a UITableViewController this way when adding it to a UINavigationController? I’ve had a hunt around the documentation with no joy so far.

Using iOS 5 with ARC but target deployment is 4.0.

  • 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-28T20:06:57+00:00Added an answer on May 28, 2026 at 8:06 pm

    I haven’t worked out why the object was being initialised twice, however I did review the steps that I used to create the .xib file and it looks like there is a problem with copying a view from a Storyboard to Interface Builder. In hindsight this makes sense, but as the view appears to copy without error and everything else seems to look okay it’s easily done.

    It would appear that similar problems were experienced by others with similar results.

    By creating a completely clean subclass of UITableViewController with a nib file (⌘-N) and copying code from the initial class into the new one I’m able to use the initial code above to alloc/init my modal view.

    BTW I was mistaken in my opening post about the nib file loading correctly when using init. It wasn’t and in fact this behaviour doesn’t happen for UITableViewController apparently where as other classes having a class name the same as the .xib file will attempt to load the .xib first.

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

Sidebar

Related Questions

I'm trying to present modally a UITableViewController from a view controller in my navigation
I'm trying to set up a NavigationController from a Modal View, but I can't
I'm trying to present a standard ViewController modally, but can't figure out how to
Hey im trying to display a modal view controller as soon as my tab
I'm trying to have a Terms of Service modal view display when my application
I am trying to open a modal view controller in the centre of my
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
Trying to load a page fragment, or at least jump to a div but
Trying to find some information on this but am unable to get any results
I'm trying to put a simple UIToolbar at the bottom of a modally presented

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.