我正在iOS上使用SWRevealViewController创建一个滑出菜单。我没有使用故事板(并以编程方式进行)。但是,左侧栏按钮项目不会显示在屏幕上。
代码段是:
-(void) viewDidLoad {
[super viewDidLoad];
MenuViewController *mvc = [[UIStoryboard storyboardWithName:@"Menu" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"MenuController"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self];
navigationController.navigationItem.leftBarButtonItem = self.settingsBarButtonItem;
self.revealController = [[SWRevealViewController alloc] initWithRearViewController:mvc frontViewController:navigationController];
self.revealController.delegate = self;
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.window.rootViewController = self.revealController;
}
-(UIBarButtonItem *) settingsBarButtonItem {
if (!_settingsBarButtonItem ) {
UIImage *moreImage = [[UIImage imageNamed:@"btn_nav_bar_more"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
_settingsBarButtonItem = [[UIBarButtonItem alloc] initWithImage:moreImage style:UIBarButtonItemStylePlain target:self.revealController action:@selector(revealToggle:)];
}
return _settingsBarButtonItem;
}