1. Custom controller switch < one >

Source: Internet
Author: User

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 >

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.