//
// SecondViewController.h
// UI3_UIViewController生命周期
//
// Created by zhangxueming on 15/7/2.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <UIKit/UIKit.h> @interface SecondViewController : UIViewController @end //
// SecondViewController.m
// UI3_UIViewController生命周期
//
// Created by zhangxueming on 15/7/2.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "SecondViewController.h" @interface SecondViewController () @end @implementation SecondViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(50, 400, self.view.frame.size.width-100, 50);
btn.backgroundColor = [UIColor whiteColor]; [btn setTitle:@"视图模式跳转-First" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn]; self.view.backgroundColor = [UIColor cyanColor];
} - (void)btnClicked
{
if ([self.view superview]) {
NSLog(@"123");
[self.view superview].backgroundColor=[UIColor redColor]; [self.view removeFromSuperview];
}
//使消失当前视图控制器视图
//[self dismissViewControllerAnimated:YES completion:nil];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#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
//
// ViewController.m
// UI3_UIViewController生命周期
//
// Created by zhangxueming on 15/7/2.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "ViewController.h"
#import "SecondViewController.h" @interface ViewController () @end @implementation ViewController
//视图控制器 //当一个视图控制器被创建,并在屏幕上显示的时候。 代码的执行顺序
//1、 alloc                                   创建对象,分配空间
//2、init (initWithNibName) 初始化对象,初始化数据
//3、loadView                          从nib载入视图 ,通常这一步不需要去干涉。除非你没有使用xib文件创建视图
//4、viewDidLoad                   载入完成,可以进行自定义数据以及动态创建其他控件
//5、viewWillAppear              视图将出现在屏幕之前,马上这个视图就会被展现在屏幕上了
//6、viewDidAppear               视图已在屏幕上渲染完成
//当一个视图被移除屏幕并且销毁的时候的执行顺序,这个顺序差不多和上面的相反
//1、viewWillDisappear            视图将被从屏幕上移除之前执行
//2、viewDidDisappear             视图已经被从屏幕上移除,用户看不到这个视图了
//3、dealloc                           视图被销毁,此处需要对你在init和viewDidLoad中创建的对象进行释放 - (void)loadView
{
[super loadView];
NSLog(@"开始加载视图");
} - (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"视图加载完成");
// Do any additional setup after loading the view, typically from a nib.
//UIViewController UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(50, 100, self.view.frame.size.width-100, 50);
btn.backgroundColor = [UIColor whiteColor]; [btn setTitle:@"视图模式跳转-Second" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn]; self.view.backgroundColor= [UIColor redColor];
} - (void)btnClicked
{
SecondViewController *svc = [[SecondViewController alloc] init]; //设置跳转模式
//UIModalTransitionStylePartialCurl 翻页效果
svc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
//显示视图控制器中的view [self presentViewController:svc animated:YES completion:nil];
} //视图将要显示
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"Appering 视图将要显示");
} //视图已经显示
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"Appeared 视图已经显示");
} //视图将要消失
- (void)viewWillDisappear:(BOOL)animated
{
NSLog(@"Disappearing 视图将要消失");
}
//视图已经消失
- (void)viewDidDisappear:(BOOL)animated
{
NSLog(@"Disappeared 视图消失");
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

UI3_UIViewController生命周期的更多相关文章

  1. react组件的生命周期

    写在前面: 阅读了多遍文章之后,自己总结了一个.一遍加强记忆,和日后回顾. 一.实例化(初始化) var Button = React.createClass({ getInitialState: f ...

  2. 浅谈 Fragment 生命周期

    版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Fragment 文中如有纰漏,欢迎大家留言指出. Fragment 是在 Android 3.0 中 ...

  3. C# MVC 5 - 生命周期(应用程序生命周期&请求生命周期)

    本文是根据网上的文章总结的. 1.介绍 本文讨论ASP.Net MVC框架MVC的请求生命周期. MVC有两个生命周期,一为应用程序生命周期,二为请求生命周期. 2.应用程序生命周期 应用程序生命周期 ...

  4. UIViewController生命周期-完整版

    一.UIViewController 的生命周期 下面带 (NSObject)的方法是NSObject提供的方法.其他的都是UIViewController 提供的方法. load   (NSObje ...

  5. angular2系列教程(十一)路由嵌套、路由生命周期、matrix URL notation

    今天我们要讲的是ng2的路由的第二部分,包括路由嵌套.路由生命周期等知识点. 例子 例子仍然是上节课的例子:

  6. Spring中Bean的作用域、生命周期

                                   Bean的作用域.生命周期 Bean的作用域 Spring 3中为Bean定义了5中作用域,分别为singleton(单例).protot ...

  7. Autofac - 生命周期

    实例生命周期决定在同一个服务的每个请求的实例是如何共享的. 当请求一个服务的时候,Autofac会返回一个单例 (single instance作用域), 一个新的对象 (per lifetime作用 ...

  8. 【微信小程序开发•系列文章六】生命周期和路由

    这篇文章理论的知识比较多一些,都是个人观点,描述有失妥当的地方希望读者指出. [微信小程序开发•系列文章一]入门 [微信小程序开发•系列文章二]视图层 [微信小程序开发•系列文章三]数据层 [微信小程 ...

  9. Xamarin.Android活动的生命周期

    一.前言 用过Android手机的人一定会发现一种现象,当你把一个应用置于后台后,一段时间之后在打开就会发现应用重新打开了,但是之前的相关的数据却没有丢失.可以看出app的“生命”是掌握在系统手上的, ...

随机推荐

  1. android手势事件 快速移动 长按触摸屏 按下触摸屏,并拖动

    /* 用户按下触摸屏.快速移动后松开 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float vel ...

  2. swift:自定义UICollectionViewFlowLayout

    写作目的 UICollectionView是ios中一个十分强大的控件,利用它能够十分简单的实现一些很好看的效果.UICollectionView的效果又依赖于UICollectionViewLayo ...

  3. linux消息队列操作

    对消息队列的操作无非有以下三种类型: 1. 打开或创建消息队列消息队列的内核持续性要求每一个消息队列都在系统范围内相应唯一的键值,所以,要获得一个消息队列的描写叙述字,仅仅需提供该消息队列的键值就可以 ...

  4. 好记心不如烂笔头之JQuery学习,第二章

    jQuery获取元素不需要担心元素不存在而报错,但是无论怎样 $("#xxx") 是一定会有返回值的,无论存不存在元素,那么依然是要对元素做判断的,判断的方法常见两种 1.看返回的 ...

  5. h5 -1

    <header></header> 页眉 主要用于页面的头部的信息介绍,也可用于板块头部 <hgroup></hgroup> 页面上的一个标题组合 一个 ...

  6. 经典排序算法总结与实现 ---python

    原文:http://wuchong.me/blog/2014/02/09/algorithm-sort-summary/ 经典排序算法在面试中占有很大的比重,也是基础,为了未雨绸缪,在寒假里整理并用P ...

  7. Is an MTD device a block device or a char device?

    转:http://www.linux-mtd.infradead.org/faq/general.html#L_mtd_what Note, you can find Ukranian transla ...

  8. LeetCode1 Two Sum

    题目 :Given an array of integers, return indices of the two numbers such that they add up to a specifi ...

  9. 关于yarn的spark配置属性

    spark1.2.0 These are configs that are specific to Spark on YARN Property Name Default Meaning  spark ...

  10. iOS ----Pods-resources.sh Permission denied

    1:执行指令 chmod a+x "路径(Pods-resources.h文件所在的路径)" 2:cd 进如pods文件夹下面 3:执行指令 第一步: sudo chmod 777 ...