Search code examples
iosiphonesidebar

Can i have two sidebars in an IOS app?


I am new to IOS app development. I am in design phase of an app i am currently developing. I would like to know if i can implement two side drawers in my IOS App i.e. one would open from the left of the screen and one would open from the right of the screen. I would like to know if there would be any problems while i submit my application on the app store?

Thanks


Solution

  • You could use third party solutions i.e. SWRevealViewController. It allows you to do exactly what you want - implementing sidebar menus both from the left and right sides. There is also an AppCoda tutorial on how to do it using SWRevealViewConttoller.

    Also, I don't see it would be a cause to be rejected from Apple. However you can read the App Store Review Guidelines on user interface. Unfortunately I cannot send a link, because of my reputation on stack.

    Here is a quick tutorial on how to add two menus using SWRevealViewController:

    Result ViewControllers Storyboard glance

    The segues are done in storyboard.

    1. Create a UIViewController in storyboard and set its class to SWRevealViewController.
    2. Create another UIViewController (MainViewController) and embed it into a UINavigationController.
    3. Drag two UIBarButtonItem's on the left and right sides of the navigation bar and create outlets for them in code.
    4. Add the below code to the MainViewController's class:

      - (void)viewDidLoad
      {
          [super viewDidLoad];
      
          if (self.revealViewController) {
              [self.leftSidebarButton setTarget: self.revealViewController];
              [self.rightSidebarButton setTarget: self.revealViewController];
              [self.leftSidebarButton setAction: @selector( revealToggle: )];
              [self.rightSidebarButton setAction: @selector( revealToggle: )];
              [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
          }
      }
      
    5. Create two UITableViewControllers which will be your menus.

    6. Control drag from the SWRevealViewController to the MainViewController's UINavigationController and set the segue class to "SWRevealViewControllerSegueSetController".
    7. Perform the same operation for both of the UITableViewControllers.
    8. Set the identifier of the segue from SWRevealViewController to MainViewController to "sw_front", set the segue identifier from the SWRevealViewController to left menu UITableViewController to "sw_rear", the right menu UITableViewController's segue's identifier must be set to "sw_right".
    9. Build and run.