练习:
1.//视图的3个状态:
a.显示前
b.正处于显示状态
c.已经被影藏
2.切换页面:ViewController和View02
复习次数:
5月26日
5月27日
5月28日
6月6日失败
代码:
//
// ViewController.m
// 0606
//
// Created by Encore on 16/6/6.
// Copyright © 2016年 trauson. All rights reserved.
//
#import "ViewController.h"
#import "View02.h"
@interface ViewController ()
@end
@implementation ViewController
//1
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"程序第一次加载视图时的调用");
self.view.backgroundColor=[UIColor yellowColor];
}
//4视图分为:消失后
-(void)viewDidDisappear:(BOOL)animated
{
NSLog(@"视图已经被影藏");
}
//2显示前
-(void)viewWillAppear:(BOOL)animated
{
NSLog(@"视图即将显示");
}
//3
-(void)viewWillDisappear:(BOOL)animated
{
NSLog(@"视图即将消失");
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
View02* myView=[[View02 alloc] init];
[self presentViewController:myView animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
#import "View02.h"
#import "ViewController.h"
@interface View02 ()
@end
@implementation View02
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor=[UIColor blackColor];
NSLog(@"View02同步显示!");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[self dismissViewControllerAnimated:YES completion:nil];
}
//4视图分为:消失后
-(void)viewDidDisappear:(BOOL)animated
{
NSLog(@"View02视图已经被影藏");
}
//2显示前
-(void)viewWillAppear:(BOOL)animated
{
NSLog(@"View02视图即将显示");
}
//3
-(void)viewWillDisappear:(BOOL)animated
{
NSLog(@"View02视图即将消失");
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will 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