//
// 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 手机设置CMWAP 接入点

    Android 手机设置CMWAP 接入点 设置--- 无限控件---移动网络设置---接入点名称----再按菜单---选择新apn 第一步,设置CMNET 上网APN 新建 APN 1.名称:cmn ...

  2. MySQL错误:Can't connect to MySQL server (10060)

    转自:http://database.51cto.com/art/201107/274565.htm 当远程连接MySQL数据库的时候显示Can't connect to MySQL server ( ...

  3. Linux显示全部执行中的进程

    Linux显示全部执行中的进程 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ ps aux | less USER PID %CPU %MEM VSZ RSS ...

  4. 云服务器 ECS Linux 误删除文件恢复方法介绍

    云服务器 ECS Linux 下,rm -rf  意味着一旦删除的文件是无法挽回的.但如果在没有文件覆盖操作的前提下,可以先尝试相关方式进行文件恢复. 本文对此进行简要说明. https://help ...

  5. Linux中如何使用gThumb批量调整图片大小

    Linux中如何使用gThumb批量调整图片大小 导读 如果你的工作涉及到图片编辑和处理,就一定会有同时对多张图片进行批量大小调整的经历.虽然大多数图片编辑应用都能够非常容易地批量调整多张图片,但对于 ...

  6. ngrok 2016版

    1. 先到http://www.ngrok.cc/下载客户端 2.进管理页面 注册登录 3.绑定域名 新增: 复制客户端id 打开该目录 按住shift 右键->在此处打开命令窗口 输入 sta ...

  7. Android基本控件之listView(三)<用ListView实现分页加载>

    我们之前讨论了ListView的基本使用方法和ListView的优化 今天我们再来讨论一个关于ListView的一个新的东西~就是分页加载.那么什么是分页加载呢?简单点说,就是"下拉刷新&q ...

  8. 看完《Don't make me think》的总结

    寒假在公司实习,然后公司人数比较少,作为一个前端实习生,分工下,就去负责了项目的业务逻辑的梳理以及页面的设计,为了让页面设计的好看,交互性好,便于用户使用,我就快速看了这本薄薄的却很有用的书.书的整体 ...

  9. 请谨慎使用 @weakify 和 @strongify

    来源:酷酷的哀殿 链接:http://www.jianshu.com/p/d8035216b257 前言 相信大部分见过 @weakify 和 @strongify 的开发者都会喜欢上这两个宏.但是很 ...

  10. 快递鸟顺丰电子面单接口API-JAVA

    一.电子面单对接案例 1.接口描述 接口支持的消息接收方式:HTTP POST 请求方法的编码格式(utf-8):"application/x-www-form-urlencoded;cha ...