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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:08:36+00:00 2026-05-29T21:08:36+00:00

I’m converting an iPhone app to be a universal app, and it’s been mostly

  • 0

I’m converting an iPhone app to be a universal app, and it’s been mostly straight forward to convert the nested tables into a UISplitViewController arrangement, but I have a remaining issue when running on an iPad that is giving me a headache.

For universal app compatibility, the ‘master’ view contains a UINavigationController that is used to navigate through a series of TableViews that each displays a menu. This works fine.

Eventually, the user arrives at content that is displayed in the detail view. Each detail view ‘chain’ is contained in a UINavigationController, as some views can drill down to show maps etc. The idea is that the popover button will live at the root level of the detail view. It’s probably important to note that the detail views are created from scratch every time that row is selected.

I’ve studied Apple’s Multiple Detail View Sample Code , and so use the master view as the UISplitViewController delegate, which provides the hide/show popover selectors, and then passes the calls down to whichever substitute detail view is selected.

When working in landscape mode, I can select different rows in the master view, and the detail views switch nicely – everything works great. It’s wonderful.

In portrait mode, things don’t work quite so well… the popover button displays correctly in the currently selected detail view when rotating to portrait, but then disappears when a row is selected (i.e. it’s somehow not being added correctly to the newly selected view’s NavBar).

I’ve added diagnostic code, and it looks like the correct calls (with correct pointers) are being made to show the popover button on the newly selected detail view. Also, I can rotate to landscape and back again, and the popover button then appears so I’m reasonably satisfied that the popover UIBarButtonItem is being hooked up to the new detail NavBar correctly.

As the detail views are not created until the row is selected, I was wondering if this was a case of the UINavigationBar not being instantiated at the time that showRootPopoverButtonItem is called (based on Apple’s sample code). This theory is supported by the fact that the popover button appears if I rotate to landscape and back again (as mentioned above) with the same view selected.

I also see this comment in Apple’s sample code, in didSelectRowAtIndexPath, and just before switching the detail views, note the use of the word ‘after’…

// Configure the new view controller's popover button (after the view has been displayed and its toolbar/navigation bar has been created).

So, I tried calling the showRootPopoverButton method again in viewWillAppear (by which time the UINavigationBar should exist), but that doesn’t cause the popover button to appear either.

I’d appreciate any thoughts and suggestions as to how to get the popover button to appear immediately when a new row is selected from the master view when in portrait mode. Thanks.

Thanks for reading this far, the relevant code is below.

From the master view, here are the UISplitViewControllerDelegate selectors,

- (void)splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController:(UIPopoverController*)pc
{

    // Keep references to the popover controller and the popover button, and tell the detail view controller to show the button.
    barButtonItem.title = @"Root View Controller";
    self.popoverController = pc;
    self.rootPopoverButtonItem = barButtonItem;
    //UIViewController <SubstitutableDetailViewController> *detailViewController = [self.splitViewController.viewControllers objectAtIndex:1];

    // ^ Apple's example, commented out, my equivalent code to obtain
    // active detail navigation controller below,

    UINavigationController *detailNavController = [self.splitViewController.viewControllers objectAtIndex:1];
    UIViewController *detailViewController = detailNavController.visibleViewController;

    [detailViewController showRootPopoverButtonItem:rootPopoverButtonItem];
}


- (void)splitViewController:(UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
     // Nil out references to the popover controller and the popover button, and tell the detail view controller to hide the button.
     UINavigationController *detailNavController = [self.splitViewController.viewControllers objectAtIndex:1];
     UIViewController *detailViewController = detailNavController.visibleViewController;
     [detailViewController invalidateRootPopoverButtonItem:rootPopoverButtonItem];
     self.popoverController = nil;
     self.rootPopoverButtonItem = nil;
}

And, very much like Apple’s example, here’s what happens when a row is selected in the master table,

if (rootPopoverButtonItem != nil)
{
    NSLog (@"show popover button");
    [newDetailViewController showRootPopoverButtonItem:self.rootPopoverButtonItem];
}

From the detail view,

- (void)showRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem
{
    NSLog (@"detailViewController (view: %p, button: %p, nav: %p): showRootPopoverButton", self, barButtonItem, self.navigationItem);

    barButtonItem.title = self.navigationItem.title;

    [self.navigationItem setLeftBarButtonItem:barButtonItem animated:NO];

    popoverButton = barButtonItem;
}


- (void)invalidateRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem
{    
    NSLog (@"detailViewController (%p): invalidateRootPopoverButton", self);

    // Called when the view is shown again in the split view, invalidating the button and popover controller.
    [self.navigationItem setLeftBarButtonItem:nil animated:NO];

    popoverButton = nil;
}
  • 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-29T21:08:37+00:00Added an answer on May 29, 2026 at 9:08 pm

    There are two things that I think could be the problem here. You should include the rest of your code. Specifically the part where you change the detail view controller when the user performs an action in the master.

    1. visibleViewController may be nil if you just instantiated detailNavController. Even if you set it’s root, there is no “visible” view controller since it actually hasn’t displayed yet. You may want to try using topViewController

    2. I’m not sure if you’re creating a new detailNavController every time the user selects something in the master but if you are, you need to pass the rootPopoverButtonItem into the detailViewController again because - (void)splitViewController: willHideViewController: withBarButtonItem: forPopoverController: only gets called automatically when the orientation changes.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am writing an app with both english and french support. The app requests
I have a reasonable size flat file database of text documents mostly saved in

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.