首页 技术 正文
技术 2022年11月16日
0 收藏 868 点赞 2,448 浏览 3560 个字
//
// 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
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,958
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,482
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,328
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,111
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,743
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,777