Add several controllers to the Uisegmentedcontrol

Source: Internet
Author: User

1 #import "RootViewController.h"2 #import "LoginViewController.h"3 #import "RegistViewController.h"4 #import "PasswardViewController.h"5 #import "RootView.h"6 7 @interfaceRootviewcontroller ()8@property (nonatomic, strong) Rootview *Rootview;9@property (nonatomic, strong) Loginviewcontroller *LOGINVC;Ten@property (nonatomic, strong) Registviewcontroller *REGISTVC; One@property (nonatomic, strong) Passwardviewcontroller *PASSWARDVC; A  - @end -  the @implementationRootviewcontroller -  -- (void) Loadview { -Self.rootview =[[Rootview alloc] Initwithframe:[uiscreen mainscreen].bounds]; +Self.view =Self.rootview; -      + } A  at  -- (void) Viewdidload { - [Super Viewdidload]; -      -     //initializing the View controller -SELF.LOGINVC =[[Loginviewcontroller alloc] init]; inSELF.REGISTVC =[[Registviewcontroller alloc] init]; -SELF.PASSWARDVC =[[Passwardviewcontroller alloc] init]; to      +      -     //segment Adding an event the [self.rootView.segment addtarget:self Action: @selector (click:) forcontrolevents:uicontroleventvaluechanged]; *      $ }Panax Notoginseng  -  the //Implement click Events +- (void) Click: (Uisegmentedcontrol *) Sender { A      the     Switch(sender.selectedsegmentindex) { +          Case 0: -             //Remove the topmost child view in the parent view $[[Self.rootView.subviews Objectatindex:0] Removefromsuperview]; $              -             //Add a new view - [Self.rootview AddSubview:self.loginVC.view]; the              -             //Display the segment selector at the outermost layerWuyi [Self.rootview bringSubviewToFront:self.rootView.segment]; the              Break; -              Wu          Case 1: -             //Remove the topmost child view in the parent view About[[Self.rootView.subviews Objectatindex:0] Removefromsuperview]; $              -             //Add a new view - [Self.rootview AddSubview:self.registVC.view]; -              A             //Display the segment selector at the outermost layer + [Self.rootview bringSubviewToFront:self.rootView.segment]; the              Break; -              $          Case 2: the             //Remove the topmost child view in the parent view the[[Self.rootView.subviews Objectatindex:0] Removefromsuperview]; the              the             //Add a new view - [Self.rootview AddSubview:self.passwardVC.view]; in              the             //Display the segment selector at the outermost layer the [Self.rootview bringSubviewToFront:self.rootView.segment]; About              Break; the              the         default: the              Break; +     } - } the @end

Add several controllers to the Uisegmentedcontrol

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.