This is a migrated thread and some comments may be shown as answers.

SideDrawer goes behind UINavigationBar when using UINavigationBarController

3 Answers 93 Views
SideDrawer
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sal
Top achievements
Rank 1
Sal asked on 12 Aug 2015, 07:19 PM
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. 

3 Answers, 1 is accepted

Sort by
0
Accepted
Adrian
Telerik team
answered on 14 Aug 2015, 01:39 PM
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
0
Sal
Top achievements
Rank 1
answered on 14 Aug 2015, 04:37 PM
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? 
0
Adrian
Telerik team
answered on 18 Aug 2015, 02:38 PM
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
Tags
SideDrawer
Asked by
Sal
Top achievements
Rank 1
Answers by
Adrian
Telerik team
Sal
Top achievements
Rank 1
Share this question
or