Green ocean
Green ocean

Reputation: 31

How to ECSlidingViewController without storyboard?

I want to use ECSlidingViewController in my iOS 4.3 applications. And I wonder how to apply this library without storyboard?

PLZ, how to? this is my code, but iOS simulator's screen is white only.

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    //self.window.backgroundColor = [UIColor whiteColor];

    FrontViewController *frontViewController = [[FrontViewController alloc] initWithNibName:@"FrontViewController" bundle:nil];
    RearViewController *rearViewController = [[RearViewController alloc] initWithNibName:@"RearViewController" bundle:nil];

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];

    // create a DDMenuController setting the content as the root
    //DDMenuController *menuController = [[DDMenuController alloc] initWithRootViewController:navigationController];
    //menuController.leftViewController = rearViewController;

    //RevealController *menuController = [[RevealController alloc] initWithFrontViewController:navigationController rearViewController:rearViewController];

    ECSlidingViewController *slidingViewController = (ECSlidingViewController *)self.window.rootViewController;
    slidingViewController.topViewController = navigationController;
    slidingViewController.underLeftViewController = rearViewController;

    self.window.rootViewController = slidingViewController;
    [self.window makeKeyAndVisible];
    return YES;
}

Upvotes: 3

Views: 4104

Answers (3)

Tim Kozak
Tim Kozak

Reputation: 4182

Here is your code

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    
(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

// Override point for customization after application launch.
FrontViewController *frontViewController = [[FrontViewController alloc] initWithNibName:@"FrontViewController" bundle:nil];
RearViewController *rearViewController = [[RearViewController alloc] initWithNibName:@"RearViewController" bundle:nil];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];

ECSlidingViewController *slidingViewController = [[ECSlidingViewController alloc] init];
slidingViewController.topViewController = navigationController;
slidingViewController.underLeftViewController = rearViewController;

self.window.rootViewController = slidingViewController;
[self.window makeKeyAndVisible];
return YES;
}

Upvotes: 7

Jess Bowers
Jess Bowers

Reputation: 2963

The primary issue in your code above is that the slidingViewController isn't being instantiated.

You need this line:

ECSlidingViewController *slidingViewController = [[ECSlidingViewController alloc] init];

Upvotes: 0

Wayne Liu
Wayne Liu

Reputation: 1291

ECSlidingViewController uses iOS5, Storyboard and ARC. To put efforts into reengineering this class, I suggest you choose other classes which are ready for lower iOS versions and not using Storyboard. Some similar examples are:

https://github.com/pkluz/ZUUIRevealController
https://github.com/mystcolor/JTRevealSidebarDemo

Upvotes: 0

Related Questions