我使用JASidePanels设置与Facebook相同的布局,但有一些限制,我希望您能帮助我:
在中央视图控制器的导航控制器中添加右键
在其他视图控制器中按下按钮后,将中心视图更改为其他视图
从左侧或右侧告诉中央视图控制器按下视图
从左侧或右侧转到标签栏视图控制器内的视图
这是我在MainAppDelegate中的实现:
/* tabbar views with their navigation controller */
SearchViewController *searchViewController = [[SearchViewController alloc]
initWithNibName:@"SearchViewController" bundle:nil];
self.searchNavController = [[UINavigationController alloc]
initWithRootViewController:searchViewController];
MainViewController *mainViewController = [[MainViewController alloc]
initWithNibName:@"MainViewController" bundle:nil];
self.mainNavController = [[UINavigationController alloc]
initWithRootViewController:mainViewController];
/* uiviewcontroller for our left side view */
SideMenuViewController *sideMenuViewController=[[SideMenuViewController alloc]
initWithNibName:@"SideMenuViewController" bundle:nil];
/* the center view of the side panel */
self.mainSidePanelviewController = [[JASidePanelController alloc] init];
self.mainSidePanelviewController.shouldDelegateAutorotateToVisiblePanel = NO;
/* set the properties of JASidePanel*/
self.mainSidePanelviewController.leftPanel = sideMenuViewController ;
self.mainSidePanelviewController.centerPanel = self.mainNavController;
[self.mainSidePanelviewController.centerPanel.navigationController
setNavigationBarHidden:YES animated:YES];
NSArray *controllers = [NSArray arrayWithObjects:
self.mainSidePanelviewController,self.searchNavController ,nil];
[self.tabController setViewControllers:controllers];
// the tab bar is our root view
self.window.rootViewController = self.tabController;
[self.window makeKeyAndVisible];
如果有一个更好的开源项目允许我做我想做的事情,请给我链接
答案 0 :(得分:0)
只需添加您自己的按钮(例如在viewDidLoad中)并指定一个选择器以显示右侧面板:
UIBarButtonItem *rightbutton = [UIBarButtonItem barItemWithImage:[UIImage imageNamed:@"rightIcon.png"] hightlightImage:[UIImage imageNamed:@"rightIcon.png"] target:self action:@selector(slideInRightHandView:)];
self.navigationItem.rightBarButtonItem = rightbutton;
答案 1 :(得分:0)
导入接口头文件
#import“UIViewController + JASidePanel.h”
在ViewController中,您要添加右键。将以下代码添加到viewDidLoad方法。
if (!self.navigationItem.rightBarButtonItem) {
UIImage* image = [UIImage imageNamed:@"rightButtonImage.png"];
CGRect frameimg = CGRectMake(0, 0, image.size.width, image.size.height);
UIButton *button = [[UIButton alloc] initWithFrame:frameimg];
[button setBackgroundImage:image forState:UIControlStateNormal];
[button addTarget:self.sidePanelController action:@selector(toggleRightPanel:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button]; }
您可以使用任何UIButton创建rightBarButtonItem。