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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:10:04+00:00 2026-05-17T23:10:04+00:00

I have a re-usable UITableViewController sub-class, call it tableVC. Selecting a table row pushes

  • 0

I have a re-usable UITableViewController sub-class, call it “tableVC”. Selecting a table row pushes that detail view controller onto the nav stack. The tableVC instance only has a valid navController when it has been pushed itself. So far so good.

I need to embed the tableVC’s view inside another view whose viewController has been pushed. Since that superview’s viewController has been pushed, it has a valid navCon. I can’t get at that navCon from the tableVC because tableVC has not been pushed, and so the otherwise perfectly re-usable tableVC cannot push details.
Is there a clean way to reference that navCon, other than hacking in a special UINavigationController variable, and if self.navigationController is nil, then access the hack? Seems like a common enough situation that there should be a best practice.
Any insights are much appreciated.
-Mike

  • 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-17T23:10:05+00:00Added an answer on May 17, 2026 at 11:10 pm

    The short answer AFAIK is no, that there is no other way to get at the navigation controller you are after.

    The medium answer is that you could override your table view controller’s navigationController property to make it writable:

    @interface myTableViewController : UITableViewController {
      UINavigationController *navigationController;
    }
    @property (nonatomic, retain) UINavigationController *navigationController;
    

    That would allow you to set it to the pushed VC’s navigation controller when you add its view as a subview. It will also still work as promised when you push it onto a navigation controller stack normally.

    The long answer is that Apple discourages what you are doing. From “About Custom View Controllers” in the View Controller Programming Guide:

    Note: If you want to divide a single
    screen into multiple areas and manage
    each one separately, use generic
    controller objects (custom objects
    descending from NSObject) instead of
    view controller objects to manage each
    subsection of the screen. Then use a
    single view controller object to
    manage the generic controller objects.
    The view controller coordinates the
    overall screen interactions but
    forwards messages as needed to the
    generic controller objects it manages.

    I have run into the problem you are describing and ended up taking an approach first suggested by Matt Gallagher on Cocoa with Love: Create a separate controller class that inherits from NSObject (instead of UIViewController) and implements UITableViewDelegate and UITableViewDataSource to manage the table view. He has sample code with his post that is extremely useful if you decide to go down this road. When I did this it largely amounted to simply changing the inheritance declaration in my custom UITableViewController subclass.

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

Sidebar

Related Questions

I have UITableViewController as the RootViewController. I need to add rows to the table
I have encountered a problem of placing data into the Table View. Here is
I have a Network Client class that is receiving a large binary block and
I have always felt that in general the main work of a class should
I have a script that appends some rows to a table. One of the
I have a dll that must be useable from C etc, so I cant
I have some questions about basic CSS that I was unable to understand or
Typically languages have keywords that you are unable to use directly with the exact
All, I currently have two projects that are under SourceSafe that I am unable
I have a C# ComServerProject that implements an out-of-proc COM server, and I've selected

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.