Created
December 21, 2018 05:06
-
-
Save arkilis/38c980c52d2b76179ad8d15a6f694622 to your computer and use it in GitHub Desktop.
Are you familar with viewWillAppear, viewDidAppear, viewDidLoad, viewWillDisappear and viewDidDisappear in Objective-C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.m | |
// TestBlock | |
// | |
// Created by Ben Liu on 14/4/17. | |
// Copyright © 2017 Ben Liu. All rights reserved. | |
// | |
#import "ViewController.h" | |
@interface ViewController (){ | |
UIViewController *anotherView; | |
} | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
NSLog(@"viewDidLoad is running"); | |
anotherView = [UIViewController new]; | |
anotherView.view.backgroundColor = [UIColor redColor]; | |
} | |
-(void)viewWillAppear:(BOOL)animated { | |
[super viewWillAppear:animated]; | |
NSLog(@"viewWillAppear is running"); | |
} | |
-(void)viewDidAppear:(BOOL)animated{ | |
NSLog(@"viewDidAppear is running"); | |
} | |
-(void)viewWillDisappear:(BOOL)animated{ | |
[super viewWillDisappear:animated]; | |
NSLog(@"viewWillDisappear is running"); | |
} | |
-(void)viewDidDisappear:(BOOL)animated{ | |
NSLog(@"viewDidDisappear is running"); | |
} | |
- (IBAction)onClickBtn:(id)sender { | |
[self presentViewController:anotherView animated:YES completion:nil]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment