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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:23:17+00:00 2026-06-13T12:23:17+00:00

I am trying to make a sidebar menu but i have a little problem.

  • 0

I am trying to make a sidebar menu but i have a little problem.

I explain :

  1. I created an UIViewController that i called sideMenuViewController
  2. In my viewController Class (the initial view controller), in the header file, i import my class SideMenuViewController and i wrote :

    -(IBAction)openSideMenu:(id)sender;

    @property(nonatomic, retain) SideMenuViewController *sideMenu;
    

The openSideMenu action is associated to the menu button.Menu button

I implemented this method like this :

- (IBAction)openSideMenu:(id)sender {
    CGRect destination = self.view.frame;

    if(destination.origin.x > 0){
        destination.origin.x = 0;
    }else{
        destination.origin.x += SideMenuX;
    }

    [UIView animateWithDuration:0.4 animations:^{
        self.view.frame = destination;
    }completion:^(BOOL finished) {
        if(finished){

        }
    }];
}

SideMenuX is a macro : #define SideMenuX 154.4

My viewDidLoad method looks like this :

- (void)viewDidLoad
{
    [super viewDidLoad];
    _sideMenu = [[SideMenuViewController alloc] init];
    [self.view sendSubviewToBack:_sideMenu.view];
    // Do any additional setup after loading the view, typically from a nib.
}

The problem is that when i click on the menu button, i get a black screen and not my side menu view.

Black screen side Bar Menu

Thank you in advance !

  • 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-13T12:23:18+00:00Added an answer on June 13, 2026 at 12:23 pm

    Two problems:

    1. You are not adding the sideMenu at all. Try adding it to the parent view (self.view.superview), which in your case most likely will be the UIWindow:
       [self.view.superview insertSubview:_sideMenu.view belowSubview:self.view];

      If you are using a navigation controller, use self.navigationController.view instead self.view.

    2. Not sure if you initialized the view with a NIB or the Storyboard (see below if you didn’t).

    Here is a working example. I created the left view controller inside the storyboard like this:

    • Throw a View Controller component on the storyboard.
    • Select the controller on the left column, and go to the Identity Inspector on the right column (alt+cmd+3):
      • Set the Class to SideMenuViewController
      • Set the Storyboard ID to SideMenuViewController

    Instantiate the controller inside viewDidLoad with

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    self.sideMenu = (SideMenuViewController*)[storyboard instantiateViewControllerWithIdentifier:@"SideMenuViewController"];
    

    then insert it as child of the superview.


    (Answering the comment below)

    This line is the problem:

    [self.view.superview addSubview:_sideMenu.view];
    

    In a NIB based project the superview is UIWindow, but in a Storyboard project, the self.view.superview of a UIViewController is nil. You can solve this, for example, adding a UINavigationViewController. Follow these steps:

    • Throw in a “Navigation Controller”
    • Delete the view controller it points to.
    • Press Ctrl and drag the pointer from the UINavigationController to your view controller, and select “root view controller” on the dialog that appears.
    • Drag the arrow pointing to your view controller to the UINavigationController (the one that marks the initial view controller, not the one that comes from UINavigationController).

    Then change your code to

    _sideMenu = [[SideMenuViewController alloc] initWithNibName:@"SideMenuViewController" bundle:nil];
    [self.navigationController.view.superview insertSubview:_sideMenu.view belowSubview:self.navigationController.view];
    

    To hide the navigation bar of the UINavigationController, select it in the Storyboard and click Hidden in the Attributes Inspector (alt+cmd+4).

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

Sidebar

Related Questions

I'm trying to make a little side-bar menu so people can access area of
I'm trying to make a sidebar which on a website which will have a
I'm trying to make a sidebar for my vbulletin skin that's expandable/collapsible. Heres my
I am trying to make resizable sidebar with custom border using .png. I have
I'm trying to make a header that goes outside the borders of my sidebar
I'm trying to make a sidebar menu sticky or not sticky based on page
I'm trying to make two columns — sidebar and content. Minimum height of each
I'm trying make an entity with doctrine that has three associations with other entities
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to make the infamous checkall checkbox for dynamically created rows from a MySQL

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.