iOS应用程序中心面板与可显示侧面板:JASidePanels [英] iOS application with center panel with revealable side panels : JASidePanels
问题描述
我使用 JASidePanels 与Facebook的布局相同,但有一些限制,我想要您帮助我:
I am using JASidePanels to have the same layout as Facebook but there is some limitation and I want you to help me to :
-
在中央视图控制器的导航控制器中添加右键
Add a right button in the navigation controller of the center view controller
在按下不同视图控制器的按钮后将中心视图更改为不同的视图
Change the center View to a different view after a button press in a different view controller
从左侧或右侧转到标签栏视图控制器内的视图
From left or right side go to a view inside tabbar view controller
这里是我在MainAppDelegate中的实现:
here is my implementation inside 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];
如果有一个更好的开源项目允许我做我想做的,我链接
if there is a better open source project that allow me to do what I want to do , just give me the link
推荐答案
-
导入界面头文件
Import the interface header file
#importUIViewController + JASidePanel.h
#import "UIViewController+JASidePanel.h"
在ViewController中,将以下代码添加到viewDidLoad方法。
In the ViewController you want to add right button. Add the following code to viewDidLoad method.
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 。
You can use any UIButton to create rightBarButtonItem.
这篇关于iOS应用程序中心面板与可显示侧面板:JASidePanels的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!