【问题标题】:MMDrawerController - How to Master-Detail SideBarMMDrawerController - 如何掌握细节侧边栏
【发布时间】:2013-10-13 11:39:50
【问题描述】:

如何将MMDrawerController 用于我的主从应用程序?

我想要DetailViewController 作为我的centerViewControllerMasterViewController 作为leftDrawerViewController


实际上这是我的代码:

AppDelegate.m

#import "AppDelegate.h"
#import "MMDrawerController.h"
#import "MMDrawerVisualState.h"
#import "MasterViewController.h"
#import "DetailViewController.h"

@interface AppDelegate ()
@property (nonatomic,strong) MMDrawerController * drawerController
@end

@implementation AppDelegate

-(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:              (NSDictionary *)launchOptions{
     UIViewController * leftDrawer = [[MasterViewController alloc] init];
     UIViewController * center = [[DetailViewController alloc] init];


     UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController:center];
     [navigationController setRestorationIdentifier:@"MMExampleCenterNavigationControllerRestorationKey"];

     self.drawerController = [[MMDrawerController alloc]
                         initWithCenterViewController:center
                         leftDrawerViewController:leftDrawer];
     [self.drawerController setRestorationIdentifier:@"MMDrawer"];
     [self.drawerController setMaximumRightDrawerWidth:200.0];
     [self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
     [self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];

     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
     [self.window setRootViewController:self.drawerController];
     // Override point for customization after application launch.
     self.window.backgroundColor = [UIColor whiteColor];
     [self.window makeKeyAndVisible];

     return YES;
}

centerViewController 保持全黑,leftDrawerViewController 只包含一个 tableView。

【问题讨论】:

  • 您的代码似乎没有问题。我在一个测试应用程序中实现了它,它显示得很好。您是否检查了中心视图属性以调查显示为黑色的中心控制器?

标签: ios tableview sidebar master-detail


【解决方案1】:

当您创建MMDrawerController 时,尝试将initWithCenterViewController 参数设置为navigationController 而不是center

【讨论】:

    猜你喜欢
    • 2012-12-11
    • 2013-11-03
    • 2015-10-27
    • 1970-01-01
    • 2011-05-29
    • 1970-01-01
    • 2011-05-27
    • 2011-03-21
    • 2012-12-29
    相关资源
    最近更新 更多