IOS: Make the left-side slide menu (Drawer type)
Here we use AMSlideMenu to achieve the effect of sliding menus on the left and right sides. Controls Support independent left-side slide, independent right-side slide, and left-side slide. Both Storyboard and xib development modes are supported. Here we will introduce the second method in xib. The development procedure is as follows: 1. Add pod "AMSlideMenu", "~> to Podfile. 1.5.3 ", import the project through pod install. 2. in the Pods Project (Note: it is not your own project), in the Pods -*. add the following line of code to the pch file: // required; otherwise, the xib method will report an error # define AMSlideMenuWithoutStoryboards3. implement a ViewController that inherits the AMSlideMenuMainViewController class. The main code is as follows: copy the code-(void) viewDidLoad {/********************************* initialization menu *** * ***************************/self. leftMenu = [[LeftMenuTVC alloc] initWithNibName: @ "LeftMenuTVC" bundle: nil]; self. rightMenu = [[RightMenuTVC alloc] initWithNibName: @ "RightMenuTVC" bundle: nil]; ***** * ************************/[super viewDidLoad]; // Do any additional setup after loading the view .} // set the menu button style on the left (similar to the operation on the right button)-(void) configureLeftMenuButton :( UIButton *) button {CGRect frame = button. frame; frame. origin = (CGPoint) {0, 0}; frame. size = (CGSize) {40, 40}; button. frame = frame; [button setImage: [UIImage imageNamed: @ "icon-menu.png"] forState: UIControlStateNormal];} copy code 4. implement a class that inherits the UITableViewController of AMSlideMenuLeftTableViewController as the main code of the Left menu (similar to the right menu): copy the code-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view from its nib. // initialize menu item self. tableData = [@ [@ "VC 1", @ "VC 2", @ "VC 3"] mutableCopy];} // click the menu item to jump to a different VC-(void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath {UINavigationController * nvc; UIViewController * rootVC; switch (indexPath. row) {case 0: {rootVC = [[FirstVC alloc] initWithNibName: @ "FirstVC" bundle: nil];} break; case 1: {rootVC = [[SecondVC alloc] initWithNibName: @ "SecondVC" bundle: nil];} break; case 2: {rootVC = [[ThirdVC alloc] initWithNibName: @ "ThirdVC" bundle: nil];} break; default: break;} nvc = [[UINavigationController alloc] initWithRootViewController: rootVC]; [self openContentNavigationController: nvc];} copy Code 5. finally, remember to do this step in AppDelegate (you can also do it elsewhere): copy the code-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {MainVC * mainVC = [[MainVC alloc] init]; UINavigationController * startNVC = [[UINavigationController alloc] initWithRootViewController: mainVC]; self. window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen] bounds]; self. window. rootViewController = startNVC; [self. window makeKeyAndVisible]; return YES ;}