iOS application with center panel with revealable side panels : JASidePanels

為{幸葍}努か 提交于 2019-12-08 09:06:43

问题


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 tell the center view controller to push a view

  • From left or right side go to a view inside tabbar view controller

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


回答1:


Just add your own button (in viewDidLoad for example) and assign a selector to show the right panel:

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




回答2:


  1. Import the interface header file

    #import "UIViewController+JASidePanel.h"

  2. 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];  }
    

You can use any UIButton to create rightBarButtonItem.



来源:https://stackoverflow.com/questions/15820455/ios-application-with-center-panel-with-revealable-side-panels-jasidepanels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!