Viewcontroller.m
#import "ViewController.h"#import "DJOneViewController.h"#import "DJTwoViewController.h"#import "DJThreeViewController.h"@interfaceViewcontroller () @property (nonatomic,strong) Djoneviewcontroller*Vc1, @property (nonatomic,strong) Djtwoviewcontroller*VC2, @property (nonatomic,strong) Djthreeviewcontroller*vc3;-(ibaction) Btn1click;-(ibaction) Btn2click;-(ibaction) Btn3click;@end@implementationViewcontroller-(Djoneviewcontroller *) VC1 {if(!_vc1) {Djoneviewcontroller*VC =[[Djoneviewcontroller alloc] init]; Vc.view.frame= CGRectMake ( -,0, -, -); SELF.VC1=VC; } return_vc1;}-(Djtwoviewcontroller *) VC2 {if(!_VC2) {Djtwoviewcontroller*VC =[[Djtwoviewcontroller alloc] init]; Vc.view.frame= CGRectMake ( -,0, -, the); SELF.VC2=VC; } return_VC2;}-(Djthreeviewcontroller *) VC3 {if(!_vc3) {Djthreeviewcontroller*VC =[[Djthreeviewcontroller alloc] init]; Vc.view.frame= CGRectMake ( -,0, -, the); SELF.VC3=VC; } return_vc3;}- (void) viewdidload {[Super viewdidload]; }- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}-(ibaction) Btn1click {[Self.vc2.view removefromsuperview]; [Self.vc3.view Removefromsuperview]; [Self.view AddSubview:self.vc1.view];}-(ibaction) Btn2click {[Self.vc1.view removefromsuperview]; [Self.vc3.view Removefromsuperview]; [Self.view AddSubview:self.vc2.view]; }-(ibaction) Btn3click {[Self.vc1.view removefromsuperview]; [Self.vc2.view Removefromsuperview]; [Self.view AddSubview:self.vc3.view];}@end
Final effect:
Sina Weibo Client (10)-Switch multiple fragment