How to use Residemenu third party storyboard

Source: Internet
Author: User

How to use Residemenu third party storyboard

Step1

create a inherit from sub-class of Residemenu Viewcontroller

Rootviewcontroller. H#import"RESideMenu.h"@interface  Rootviewcontroller:residemenu@end

Associate Rootviewcontroller in storyboard and set it as the root view

Step 2

add a navigation controller and Viewcontroller to the storyboard, and Add the storyboard ID to the navigation controller, Click item to drag and drop the right mouse button, select presentLeftmenuviewcontroller, click on the item will appear drawer effect

Step 3

Add a Viewcontroller in storyboard, as a view of the drawer display, add storyboard ID

Step4

Finally, add code to the ROOTVIEWCONTROLLER.M to achieve the drawer effect

#import "RootViewController.h"#import "ViewController.h"#import "RESideMenu.h"@interfaceRootviewcontroller () <RESideMenuDelegate>@end@implementationRootviewcontroller- (void) awakefromnib{Self.contentviewcontroller= [Self.storyboard instantiateviewcontrollerwithidentifier:@"Contentviewcontroller"];//self.contentviewcontroller = self;Self.leftmenuviewcontroller = [Self.storyboard instantiateviewcontrollerwithidentifier:@"Leftmenuviewcontroller"]; Self.menupreferredstatusbarstyle=uistatusbarstylelightcontent; Self.contentviewshadowcolor=[Uicolor Blackcolor]; Self.contentviewshadowoffset= Cgsizemake (0,0); Self.contentviewshadowopacity=0.6; Self.contentviewshadowradius= A; Self.contentviewshadowenabled=NO;//Self.rightmenuviewcontroller = [Self.storyboard instantiateviewcontrollerwithidentifier:@] Rightmenuviewcontroller "];}

Note: Leftviewcontroller can be a tableview, click the Jump page effect will contentviewcontroller change, key implementation code

@interfaceDemoleftmenuviewcontroller () @property (Strong, ReadWrite, nonatomic) UITableView*TableView;@end@implementationDemoleftmenuviewcontroller- (void) viewdidload{[Super Viewdidload]; Self.tableview=({UITableView*tableview = [[UITableView alloc] Initwithframe:cgrectmake (0, (Self.view.frame.size.height- Wu*5) /2.0f, Self.view.frame.size.width, Wu*5) Style:uitableviewstyleplain]; Tableview.autoresizingmask= Uiviewautoresizingflexibletopmargin | Uiviewautoresizingflexiblebottommargin |Uiviewautoresizingflexiblewidth; TableView.Delegate=Self ; Tableview.datasource=Self ; Tableview.opaque=NO; Tableview.backgroundcolor=[Uicolor Clearcolor]; Tableview.backgroundview=Nil; Tableview.separatorstyle=Uitableviewcellseparatorstylenone; Tableview.bounces=NO; Tableview.scrollstotop=NO;    TableView;    }); [Self.view AddSubview:self.tableView];}#pragmaMark-#pragmaMark UITableView delegate-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{[TableView Deselectrowatindexpath:indexpath Animated:yes]; Switch(indexpath.row) { Case 0: [Self.sidemenuviewcontroller setcontentviewcontroller:[[uinavigationcontroller alloc] InitWithRootViewCon Troller:[self.storyboard Instantiateviewcontrollerwithidentifier:@"Firstviewcontroller"] ] [animated:yes];            [Self.sidemenuviewcontroller Hidemenuviewcontroller];  Break;  Case 1: [Self.sidemenuviewcontroller setcontentviewcontroller:[[uinavigationcontroller alloc] InitWithRootViewCon Troller:[self.storyboard Instantiateviewcontrollerwithidentifier:@"Secondviewcontroller"] ] [animated:yes];            [Self.sidemenuviewcontroller Hidemenuviewcontroller];  Break; default:             Break; }}#pragmaMark-#pragmaMark UITableView datasource-(cgfloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) indexpath{return  Wu;}-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{return 1;}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) sectionindex{return 5;}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{StaticNSString *cellidentifier =@"Cell"; UITableViewCell*cell =[TableView Dequeuereusablecellwithidentifier:cellidentifier]; if(Cell = =Nil) {Cell=[[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; Cell.backgroundcolor=[Uicolor Clearcolor]; Cell.textLabel.font= [Uifont fontwithname:@"Helveticaneue"Size +]; Cell.textLabel.textColor=[Uicolor Whitecolor]; Cell.textLabel.highlightedTextColor=[Uicolor Lightgraycolor]; Cell.selectedbackgroundview=[[UIView alloc] init]; } Nsarray*titles = @[@"Home",@"Calendar",@" Profile",@"Settings",@"Log out"]; Nsarray*images = @[@"Iconhome",@"Iconcalendar",@"Iconprofile",@"iconsettings",@"Iconempty"]; Cell.textLabel.text=Titles[indexpath.row]; Cell.imageView.image=[UIImage Imagenamed:images[indexpath.row]]; returncell;}

How to use Residemenu third party storyboard

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.