版权声明:本文为延成原创文章,转载请标明出处
#import "ViewController.h"
#import "ViewController2.h"
@interface ViewController ()
@end
@implementation ViewController
//1.系统调用
//2.控制器的view加载完毕的时候调用
//3.控件的初始化,数据的初始化
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"viewDidLoad 视图第一次加载");
self.view.backgroundColor=[UIColor grayColor];
}
-(void)viewWillAppear:(BOOL)animated{
NSLog(@"viewWillAppear 视图即将显示");
}
- (void)viewDidAppear:(BOOL)animated{
NSLog(@"viewDidAppear 视图已经显示");
}
- (void)viewWillDisappear:(BOOL)animated{
NSLog(@"viewWillDisappear 视图即将消失");
}
- (void)viewDidDisappear:(BOOL)animated{
NSLog(@"viewDidDisappear 视图已经消失");
}
//1.系统调用
//2.内存过低警告时调用
//3.除去一些不必要的内存,去除耗时内存
- (void)didReceiveMemoryWarning{
[super didReceiveMemoryWarning];
self.dataArr = nil;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
ViewController2 *cViewC2=[[ViewController2 alloc]init];
cViewC2.modalPresentationStyle=UIModalPresentationFullScreen;
[self presentViewController:cViewC2 animated:YES completion:nil];
}
@end
#import "ViewController2.h"
@interface ViewController2 ()
@end
@implementation ViewController2
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor=[UIColor greenColor];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end