Ui1_viewcontroller View switching and appdelegate

Source: Internet
Author: User

thirdviewcontroller.h//Ui1_viewcontroller View Toggle and appdelegate////Created by zhangxueming on 15/7/3.//Copyright (c) 2015 zhangxueming.  All rights reserved.//#import <UIKit/UIKit.h> @interface thirdviewcontroller:uiviewcontroller@end////  thirdviewcontroller.m//Ui1_viewcontroller View Toggle and appdelegate////Created by zhangxueming on 15/7/3.//Copyright (c) 2015 Zhangxueming. All rights reserved.//#import "ThirdViewController.h" @interface Thirdviewcontroller () @end @implementation    thirdviewcontroller-(void) viewdidload {[Super viewdidload];    Do any additional setup after loading the view.        Self.view.backgroundColor = [Uicolor Greencolor];    UIButton *btn = [UIButton Buttonwithtype:uibuttontypesystem];    Btn.frame = CGRectMake (self.view.frame.size.width-40, 50);    Btn.backgroundcolor = [Uicolor Whitecolor];    [BTN settitle:@ "Toggle view to Secondview" forstate:uicontrolstatenormal]; [Btn addtarget:self Action: @selector (btnclicked) Forcontrolevents:uicontroLeventtouchupinside];    Btn.tag = 100; [Self.view addsubview:btn];} -(void) btnclicked{[self Dismissviewcontrolleranimated:yes completion:nil];}    -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} /* #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before Nav igation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using [SEG    UE Destinationviewcontroller]. Pass the selected object to the new view Controller.} */@end////secondviewcontroller.h//ui1_viewcontroller view Toggle and appdelegate////Created by zhangxueming on 15/7/3.//Copyri Ght (c) 2015 zhangxueming.  All rights reserved.//#import <UIKit/UIKit.h> @interface secondviewcontroller:uiviewcontroller@end//// secondviewcontroller.m//Ui1_viewcontroller View Toggle and appdelegate////Created by zhangxueming on 15/7/3.//Copyright (c) 2015 Year ZHANGXUeming. All rights reserved.//#import "SecondViewController.h" #import "AppDelegate.h" #import "ThirdViewController.h" @    Interface Secondviewcontroller () @end @implementation secondviewcontroller-(void) viewdidload {[Super viewdidload];    Do any additional setup after loading the view.    Self.view.backgroundColor = [Uicolor Redcolor];    UIApplication *app = [UIApplication sharedapplication];    Appdelegate *delegate = app.delegate;    [Delegate.sharearray addobject:@ "three"];        NSLog (@ "Sharearray =%@", Delegate.sharearray);    UIButton *btn1 = [UIButton Buttonwithtype:uibuttontypesystem];    Btn1.frame = CGRectMake (self.view.frame.size.width-40, 50);    Btn1.backgroundcolor = [Uicolor Whitecolor];    [Btn1 settitle:@ "Toggle view to Firstview" forstate:uicontrolstatenormal];    [Btn1 addtarget:self Action: @selector (btnclicked:) forcontrolevents:uicontroleventtouchupinside];    Btn1.tag = 100;        [Self.view ADDSUBVIEW:BTN1]; UIButton *btn2 = [UIButton Buttonwithtype:uibuTtontypesystem];    Btn2.frame = CGRectMake (self.view.frame.size.width-40, 50);    Btn2.tag = 200;    Btn2.backgroundcolor = [Uicolor Whitecolor];    [Btn2 settitle:@ "Toggle view to Thirdview" forstate:uicontrolstatenormal];    [Btn2 addtarget:self Action: @selector (btnclicked:) forcontrolevents:uicontroleventtouchupinside];    [Self.view ADDSUBVIEW:BTN2]; }-(void) btnclicked: (UIButton *) btn{if (btn.tag==100) {[Self dismissviewcontrolleranimated:yes completion:nil]    ;        } else if (Btn.tag ==200) {Thirdviewcontroller *TVC = [[Thirdviewcontroller alloc] init];        Tvc.modaltransitionstyle = Uimodaltransitionstylefliphorizontal;    [Self PRESENTVIEWCONTROLLER:TVC animated:yes completion:nil];    }}-(void) Viewwillappear: (BOOL) animated{[Super viewwillappear:animated]; NSLog (@ "Secondview will be Displayed");}    -(void) Viewdidappear: (BOOL) animated{[Super viewdidappear:animated]; NSLog (@ "Secondview already shown");} -(void) didreceivememorywarning {[Super DidreceivemeMorywarning]; Dispose of any resources the can be recreated.} /* #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before Nav igation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using [SEG    UE Destinationviewcontroller]. Pass the selected object to the new view Controller.} */@end

 

appdelegate.h//Ui1_viewcontroller View Toggle and appdelegate////Created by zhangxueming on 15/7/3.//Copyright (c) 2015 Z Hangxueming. All rights reserved.//#import <UIKit/UIKit.h> #import <CoreData/CoreData.h> @interface appdelegate: Uiresponder <UIApplicationDelegate> @property (retain, nonatomic) Nsmutablearray *sharearray; @property (Strong, nonatomic) UIWindow *window; @property (ReadOnly, Strong, nonatomic) Nsmanagedobjectcontext *managedobjectcontext;@ Property (ReadOnly, Strong, nonatomic) Nsmanagedobjectmodel *managedobjectmodel; @property (ReadOnly, Strong, Nonatomic ) Nspersistentstorecoordinator *persistentstorecoordinator;-(void) savecontext;-(Nsurl *) applicationdocumentsdirectory; @end////appdelegate.m//ui1_viewcontroller view toggle and Appdelegate pass////Created by Zhangxueming on 15/7/3.//Copyright (c) 2015 zhangxueming. All rights reserved.//#import "AppDelegate.h" @interface appdelegate () @end @implementation appdelegate-(instancetype) init{self = [super init];    if (self) {self.sharearray = [Nsmutablearray array]; } return self;} -(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {//    Override point for customization after application launch.    Get the current application unique object UIApplication *app=[uiapplication Sharedapplication] with a single-instance method;        Gets the proxy object for the current application appdelegate *delegate = app.delegate;    [Delegate.sharearray addobject:@ "one"];        NSLog (@ "Sharearray =%@", Delegate.sharearray); return YES;}

 

viewcontroller.h//Ui1_viewcontroller View Toggle and appdelegate////Created by zhangxueming on 15/7/3.//Copyright (c) 2015 Year zhangxueming.  All rights reserved.//#import <UIKit/UIKit.h> @interface viewcontroller:uiviewcontroller@end//// viewcontroller.m//Ui1_viewcontroller View Toggle and appdelegate////Created by zhangxueming on 15/7/3.//Copyright (c) 2015 Zhan Gxueming. All rights reserved.//#import "ViewController.h" #import "AppDelegate.h" #import "SecondViewController.h" @interface    Viewcontroller () @end @implementation viewcontroller-(void) viewdidload {[Super viewdidload];    Additional setup after loading the view, typically from a nib.    UIApplication *app = [UIApplication sharedapplication];    Appdelegate *delegate = app.delegate;    [Delegate.sharearray addobject:@ ""];        NSLog (@ "Sharearray =%@", Delegate.sharearray);    UIButton *btn = [UIButton Buttonwithtype:uibuttontypesystem]; Btn.frame = CGRectMake (+, +, self.view.frame.size.width-40, 50);    [BTN settitle:@ "Toggle view to Secondview" forstate:uicontrolstatenormal];    Btn.backgroundcolor = [Uicolor Whitecolor];    [Btn addtarget:self Action: @selector (btnclicked) forcontrolevents:uicontroleventtouchupinside];    [Self.view ADDSUBVIEW:BTN]; Self.view.backgroundColor = [Uicolor cyancolor];}    -(void) btnclicked{secondviewcontroller *svc = [[Secondviewcontroller alloc] init];    Set the view toggle mode Svc.modaltransitionstyle = Uimodaltransitionstylecrossdissolve; [Self presentviewcontroller:svc animated:yes completion:nil];}    -(void) Viewwilldisappear: (BOOL) animated{[Super viewwilldisappear:animated]; NSLog (@ "Firstview will Disappear");}    -(void) Viewdiddisappear: (BOOL) animated{[Super viewdiddisappear:animated]; NSLog (@ "Firstview has disappeared");}    -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} @end

Ui1_viewcontroller View switching and appdelegate

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.