3

我想在我的 iOS 4.3 应用程序中使用 ECSlidingViewController。我想知道如何在没有情节提要的情况下应用这个库?

LZ,怎么办?这是我的代码,但 iOS 模拟器的屏幕只有白色。

 - (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;
}
4

3 回答 3

7

这是你的代码

- (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;
}
于 2013-02-25T09:13:53.603 回答
0

上面代码中的主要问题是slidingViewController 没有被实例化。

你需要这一行:

ECSlidingViewController *slidingViewController = [[ECSlidingViewController alloc] init];
于 2012-08-13T17:00:46.193 回答
0

ECSlidingViewController 使用 iOS5、Storyboard 和 ARC。为了努力重新设计这个类,我建议你选择其他为低 iOS 版本做好准备而不使用 Storyboard 的类。一些类似的例子是:

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

于 2012-08-02T18:05:22.813 回答