Tangled for several days, finally determined to start to build their own notepad.
Written in the front: These two days are some hesitation, plus a bad cold, uncomfortable to die. Thinking some confusion, the interface thought about a bit, the beginning of a random. But the first step is finally taken.
Set Rootviewcontroller to Tabbar
Application.statusbarhidden = YES; = [[UIWindow alloc]init]; = [[UIScreen mainscreen]bounds]; = [[Csmainbarcontroller alloc]init]; [Self.window makekeyandvisible ];
Use the Tabbarcontroller above the Uinavcontroller on the plus Tableviewcontroller code as follows:
- (void) viewdidload {[Super viewdidload]; //Do any additional setup after loading the view.//Csminetableviewcontroller *minetabelview = [[Csminetableviewcontroller alloc]init];Csminetableviewcontroller *minetable =[[Csminetableviewcontroller alloc]init]; [Self settabbarcontroller:minetable Title:@"About Me"Image@"Tabbar_profile_os7"Selectimage:@"tabbar_profile_selected"]; Csdiarytableviewcontroller*diarytable =[[Csdiarytableviewcontroller alloc]init]; [Self settabbarcontroller:diarytable Title:@"haha"Image@"Tabbar_profile_os7"Selectimage:@"tabbar_profile_selected"]; Cssettingviewcontroller*setview =[[Cssettingviewcontroller alloc]init]; [Self Settabbarcontroller:setview Title:@"I 'm hungry."Image@"Tabbar_profile_os7"Selectimage:@"tabbar_profile_selected"]; Csduanziviewcontroller*duanzi =[[Csduanziviewcontroller alloc]init]; [Self Settabbarcontroller:duanzi Title:@"I 'm hungry."Image@"Tabbar_profile_os7"Selectimage:@"tabbar_profile_selected"];}/** * set the corresponding Tabbar properties * * @param CHILDVC < #childVC description#> * @param tile < #tile descriptio n#> * @param image < #image description#> * @param selectimage < #selectImage description#>*/-(void) Settabbarcontroller: (Uiviewcontroller *) CHILDVC Title: (NSString *) Tile Image: (NSString *) image selectimage: ( NSString *) selectimage{//Childvc.title =tile;//childVC.tabBarItem.image = [UIImage imagenamed:image];//childVC.tabBarItem.selectedImage = [UIImage imagenamed:selectimage];ChildVC.view.backgroundColor=Csrandomcolor; ChildVC.tabBarItem.title=Tile; ChildVC.tabBarItem.image=[UIImage Imagenamed:image]; ChildVC.tabBarItem.selectedImage=[UIImage Imagenamed:selectimage]; [Self ADDCHILDVIEWCONTROLLER:CHILDVC]; Csnavigationviewcontroller*mynav =[[Csnavigationviewcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:CHILDVC]; [Self Addchildviewcontroller:mynav];}
By reconstructing the push method in NAV to determine the corresponding data: Judging whether the viewcontroller through push is present, count>0 will hide the corresponding Tabbar
/* * * */-(void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated{ if (self.viewcontrollers.count>0) { // If the push is not in the stack-bottom controller, viewcontroller.hidesbottombarwhenpushed = YES; } [Super Pushviewcontroller:viewcontroller Animated:yes];}
Set the corresponding pseudo-data to the corresponding sub-view, and do the corresponding click time Jump:
-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {#warningIncomplete method implementation.//Return The number of the rows in the section. return -;}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {StaticNSString * ID =@"Cell"; UITableViewCell*cell =[TableView Dequeuereusablecellwithidentifier:id]; if(!cell) {Cell=[[UITableViewCell Alloc]initwithstyle:uitableviewcellstyledefault Reuseidentifier:id]; } Cell.textLabel.text= [NSString stringWithFormat:@"I'm the first%ld .",(Long) Indexpath.row]; returncell;}-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{Uiviewcontroller*myview =[[Uiviewcontroller alloc]init]; MyView.view.backgroundColor=[Uicolor Redcolor]; Myview.title=@"Diary Jump"; [Self.navigationcontroller Pushviewcontroller:myview animated:yes];}
corresponding to the top of the Uibarbuttonitem click, to establish the corresponding Uibarbuttonitem classification
// Refactoring Code Implementation click Self.navigationItem.leftBarButtonItem = [Uibarbuttonitem itemwithimage:@ "navigationbar_friendsearch " highimage:@"navigationbar_friendsearch_highlighted" target:self Action: @selector (POP)]; -(void) pop{ *aboutview = [[Uiviewcontroller alloc]init]; [Aboutview.view Setbackgroundcolor:[uicolor Redcolor]; [Self.navigationcontroller Pushviewcontroller:aboutview animated:yes];}
The corresponding code in the classification:
+ (Uibarbuttonitem *) Itemwithimage: (NSString *) imageName highimage: (NSString *) highimage target: (ID) Target action: (SEL) action{UIButton*button =[[UIButton alloc]init];//button Setimage:imagename forstate:<# (uicontrolstate) #>[button Setbackgroundimage:[uiimage Imagenamed:imagename] forstate:uicontrolstatenormal]; [Button Setbackgroundimage:[uiimage imagenamed:highimage] forstate:uicontrolstatehighlighted]; //button.frame.size = button.currentBackgroundImage.size;CGRect frame =Button.frame; Frame.size=button.currentBackgroundImage.size; Button.frame=frame; [Button Addtarget:target action:action forcontrolevents:uicontroleventtouchupinside]; return[[Uibarbuttonitem Alloc]initwithcustomview:button];
}
Code Building Notepad Framework (i)