I. Custom controller switching: On the same controller, show different controllers, similar to Tabbar
Two. What do I do? (Problem resolution Steps)
1. Create several controllers: Oneviewcontroller Twoviewcontroller .....
2. Define a realistic controller:
Defined:
@property (nonatomic, weak) Uiviewcontroller *SHOWINGVC;
self.childviewcontrollers= @[
[[Zsoneviewcontroller alloc] init],
[[Zstwoviewcontroller alloc] init],
[[Zsthreeviewcontroller alloc] init]
];
Or
[Self Addchildviewcontroller:[[zsoneviewcontroller alloc] init]];
[Self Addchildviewcontroller:[[zstwoviewcontroller alloc] init]];
[Self Addchildviewcontroller:[[zsthreeviewcontroller alloc] init]];
3. Core steps: 3.1. Remove the view on the real controller and get to the controller to be displayed and assign to the displayed controller--Add the displayed controller to the host controller
Remove the view from other controllers
[Self.showingVc.view Removefromsuperview];
Where to get the Controller (index)
Nsuinteger index = [button.superview.subviews Indexofobject:button];
Add view for Controller
SELF.SHOWINGVC = Self.childviewcontrollers[index];
Self.showingVc.view.frame = CGRectMake (0, Self.view.frame.size.width, self.view.frame.size.height-64);
[Self.view AddSubview:self.showingVc.view];
Knowledge Point Supplement:
Remove the first controller from the childviewcontrollers array
[Self.childviewcontrollers[0] removefromparentviewcontroller];
1. Custom controller switch < one >