iOS development from getting started to mastering--uiviewcontroller use

Source: Internet
Author: User

Uiviewcontroller use: Jump from viewcontroller.m to viewcontroller02.m,viewcontroller.m life cycle problem, ViewController02 disappear and then show Viewcontroller process
VIEWCONTROLLER.M inside the code:

#import "ViewController.h" #import "ViewController02.h"  @interface viewcontroller ()@end @implementation viewcontroller //When the screen is clicked, call this function- (void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (uievent *) event{//Create a View controller 2ViewController02 *VC =[[viewcontroller02 Alloc]init];//Display a new view controller to the screen    //P1: New View Controller Object    //P2: Using animations to toggle animation effects    //P3: Function call after switching over, no direct nil transfer required[ SelfPRESENTVIEWCONTROLLER:VC Animated:YESCompletion:Nil];}//The first time the program loads the view is called- (void) Viewdidload {[SuperViewdidload];additional setup after loading the view, typically from a nib.     Self. View. BackgroundColor=[UicolorBluecolor];NSLog(@"Viewdidload load view for the first time");}Call this function when the view controller's view is about to be displayed//View divided into: 1 before display (not shown) 2 is in the display state 3 is already hidden//Parameter: Indicates whether the display is switched after animation//Each time the view is displayed, it will be called- (void) Viewwillappear: (BOOL) animated{NSLog(@"Viewwillappear view is about to be displayed");}//When the view is about to disappear, call this function//Parameter: Indicates whether the animation switch disappears after the call//Current status: View or display on screen- (void) Viewwilldisappear: (BOOL) animated{NSLog(@"Viewdiddisappear view is about to disappear");}Call this function immediately after the view has been displayed to the screen//Parameter: Indicates whether to invoke animation toggle display//Current status: Already displayed on the screen- (void) Viewdidappear: (BOOL) animated{NSLog(@"The Viewdidappear view has been displayed");}//The current view has disappeared from the screen//Parameter: Indicates whether the animation is invoked//Current status: The current View control view has disappeared from the screen- (void) Viewdiddisappear: (BOOL) animated{NSLog(@"Viewdiddisappear view has disappeared");} - (void) Didreceivememorywarning {[SuperDidreceivememorywarning];//Dispose of any resources, can be recreated.}@end

To create a ViewController02, the code in the VIEWCONTROLLER02.M is as follows:

#import "ViewController02.h"  @interface ViewController02 ()@end @implementation ViewController02 - (void) Viewdidload {[SuperViewdidload];additional setup after loading the view.    //Controller 2 is in red color     Self. View. BackgroundColor=[UicolorRedcolor];}//When you click on the interface screen of the current controller 2- (void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (uievent *) event{//Make the current controller disappear    //P1: Whether there is an animation effect    //P2: Whether to invoke the function block block operation after the end[ SelfDismissviewcontrolleranimated:YESCompletion:Nil];} - (void) Didreceivememorywarning {[SuperDidreceivememorywarning];//Dispose of any resources, can be recreated.}/ * #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before navigation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using    [Segue Destinationviewcontroller]. Pass the selected object to the new view Controller.} */@end

iOS development from getting started to mastering--uiviewcontroller use

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.