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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:22:26+00:00 2026-06-13T05:22:26+00:00

I am trying to implement a simple UISplitViewController where when in portrait mode the

  • 0

I am trying to implement a simple UISplitViewController where when in portrait mode the master view is hidden and appears with a button in a popover.

My AppDelegate is set up like this:

       - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

            // Override point for customization after app launch.
            self.splitViewController =[[UISplitViewController alloc]init];
            self.rootViewController=[[RootViewController alloc]init];
            self.detailViewController=[[FirstDetailViewController alloc]init];

            UINavigationController *rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController];
            UINavigationController *detailNav=[[UINavigationController alloc]initWithRootViewController:detailViewController];


            self.splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailNav,nil];
            self.splitViewController.delegate=self.detailViewController;
            splitViewController.presentsWithGesture = NO;

            // Add the split view controller's view to the window and display.
            [self.window setRootViewController:self.splitViewController];

[window makeKeyAndVisible];

        return YES;
    }

in FirstDetailViewController I set up a button like this:

UIImage *buttonImage = [UIImage imageNamed:@"button-menu.png"];
    UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [aButton setImage:buttonImage forState:UIControlStateNormal];
    aButton.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
    [aButton addTarget:self action:@selector(showNavigation) forControlEvents:UIControlEventTouchUpInside];
    aBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:aButton];
    self.appDelegate.rootPopoverButtonItem = aBarButtonItem;

showNavigation looks like this:

-(void)showNavigation{

    NSLog(@"I am in show navigation and pc=%@",self.popoverController);

    [self.popoverController presentPopoverFromRect:self.view.frame
                                            inView:self.view
                          permittedArrowDirections:UIPopoverArrowDirectionAny
                                          animated:YES];
}

When I initially load the app and press the button I get an NSLog of

I am in show navigation and pc=(null)

And the pop over dosen’t show. Now when I rotate the device to landscape mode, and then back to portrait, the master view hides and shows as expected, and the button now works in portrait mode.

Here is the code that handles the rotation:

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


    [[self navigationItem] setLeftBarButtonItem:aBarButtonItem];
    [self setPopoverController:pc];
    self.appDelegate.rootPopoverButtonItem = aBarButtonItem;

}


// Called when the view is shown again in the split view, invalidating the button and popover controller.
- (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
    [[self navigationItem] setLeftBarButtonItem:nil];
    [self setPopoverController:nil];
    self.appDelegate.rootPopoverButtonItem = aBarButtonItem;

}

How do I get the popovercontroller to not be null before any rotation occurs?

  • 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-13T05:22:27+00:00Added an answer on June 13, 2026 at 5:22 am

    Ok turns out I had an if in my willHideViewController which did not include the [self setPopoverController:pc]; line. duh!

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

Sidebar

Related Questions

I'm trying to implement simple Event Bus I started like this: public class RegistrationData
Trying to implement a simple notification system based on private pub ( something like
I'm trying to implement a simple layout, closely represented like this: _________________________ | |
I'm trying to implement a simple Java like language parser in sablecc, although I'm
I've been trying to implement simple low level keyhook using JNI and all went
I'm getting acquanted with Core Animation and trying to implement simple movement along a
Iam trying to implement a simple JMS(traditional not using springs) code in eclipse using
Just trying to implement a simple audit logging solution with Grails 2.0.2 and it
I am trying to implement a simple login servlet but it's not working properly.
I am trying to implement a simple observer pattern to update widgets with relevant

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.