IOS: Make the left-side slide menu (Drawer type)

Source: Internet
Author: User

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 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.