2013-04-04 36 views
0

我使用JASidePanels有佈局像Facebook一樣的,但有一些限制,我要你幫我:的iOS應用程序與revealable側面板中央畫面:JASidePanels

  • 添加右鍵在中心視圖控制器

  • 更改中心查看到不同的視圖中的按鈕按下後在不同的視圖控制器

  • 從左側或右側告訴噸的導航控制器他居中視圖控制器推視圖

  • 從左側或右側去的TabBar視圖控制器內部的視圖

這裏是我的內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

如果你能告訴我如何訪問側面板的uinavigationbar,因爲我需要添加一個正確的按鈕 – Aladin 2013-04-04 23:00:32

+0

你最終解決了嗎? – croigsalvador 2013-11-12 17:05:31

回答

0

只需添加自己的按鈕(在viewDidLoad for exa mple)和分配一個選擇器,以顯示右面板:

UIBarButtonItem *rightbutton = [UIBarButtonItem barItemWithImage:[UIImage imageNamed:@"rightIcon.png"] hightlightImage:[UIImage imageNamed:@"rightIcon.png"] target:self action:@selector(slideInRightHandView:)]; self.navigationItem.rightBarButtonItem = rightbutton;

0
  1. 導入接口頭文件

    #進口 「的UIViewController + JASidePanel.h」

  2. 在的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。

相關問題