SideDrawer goes behind UINavigationBar when using UINavigationBarController

4 posts, 1 answers
  1. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 12 Aug 2015 Link to this post

    I don't know if this due to how I'm setting things up or if there's an additional piece that I need to implement but I can't seem to get the SideDrawer to push the NavigationBar when shown, instead it slides the view under the bar and shows up behind the navigation bar as well. I know that if I follow the example and just add a NavigationBar programmatically it will work but I'm using a NavigationController within a Storyboard and can't seem to get it to work properly. 
  2. Answer
    Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 14 Aug 2015 Link to this post

    Hi Sal,

    Thank you for contacting us.
    To show the side drawer over the navigation bar of your UINavigationController you should use TKSideDrawerController that contains the UINavigationController. If the navigation controller is the root view controller you should create this in the application:didFinishLaunchingWithOptions: method of the AppDelegate. Please consider the code snippet below:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
         
        UINavigationController *nav = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"NavigationController"];
        TKSideDrawerController *sideDrawerController = [[TKSideDrawerController alloc] initWithContent:nav];
         
        self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
        self.window.rootViewController = sideDrawerController;
        [self.window makeKeyAndVisible];
         
        return YES;
    }

    I hope this helps. If you need further assistance, I will be glad to help.

    Regards,
    Adrian
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 14 Aug 2015 in reply to Adrian Link to this post

    Thanks Adrian, makes sense that I need to use the SideDrawerController as the root view for the navigation bar in order for it work (and I just did a quick test and it works now). For a follow up question, how would I then setup my custom TKSideDrawerView with the SideDrawerController or what's the preferred method for setting up the side menu content with the SideDrawerController? 
  5. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 18 Aug 2015 Link to this post

    Hi Sal,

    TKSideDrawerController has a side drawer attached to it by default. This means that you don't need to create TKSideDrawerView anymore, you should configure the side drawer attached to the side drawer controller. The attached TKSideDrawer instance can be configured from any UIViewController that is contained by the TKSideDrawerController through a property called sideDrawer. A possible way to configure the side drawer is to create your custom UINavigationController subclass and create a method to setup the side drawer. Please consider the code snippet below:
    @interface MyNavigationController : UINavigationController
     
    - (void)setupSideDrawer;
     
    @end
     
    @implementation MyNavigationController
     
    - (void)setupSideDrawer
    {
        TKSideDrawerSection *section = [self.sideDrawer addSectionWithTitle:@"Navigation"];
        [section addItemWithTitle:@"Item 1"];
    }
     
    @end

    And then after you attach the navigation controller to the side drawer controller in your AppDelegate, you should call this method:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
         
        MyNavigationController *nav = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"NavigationController"];
        TKSideDrawerController *sideDrawerController = [[TKSideDrawerController alloc] initWithContent:nav];
        [nav setupSideDrawer];
         
        self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
        self.window.rootViewController = sideDrawerController;
        [self.window makeKeyAndVisible];
         
        return YES;
    }

    I hope this helps. Should you have further questions, do not hesitate to contact us.

    Regards,
    Adrian
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner