#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
+(void)initialize{
[super initialize];
//1
}
- (instancetype)init
{
self= [superinit];
if(self) {
}
return self;
}
- (void)viewDidLoad {//4
[super viewDidLoad];
UIButton* btn = [[UIButton alloc]initWithFrame:CGRectMake(10, 10,200, 200)];
btn.backgroundColor = [UIColor redColor];
[self.view addSubview:btn];
[btnaddTarget:self action:@selector(didpush) forControlEvents:(UIControlEventTouchUpInside)];
}
-(void)didpush{
UIViewController * vc = [[UIViewController alloc]init];
vc.view.backgroundColor = [UIColor grayColor];
[self presentViewController:vc animated:YES completion:^{
nil;
}];
}
- (instancetype)initWithCoder:(NSCoder*)coder//2
{
self= [superinitWithCoder:coder];
if(self) {
}
return self;
}
//-(void)awakeFromNib{}
- (void)loadView{
[super loadView];
// Do any additional setup after loading the view, typically from a nib.
UIView* views = [[UIViewalloc]initWithFrame:CGRectMake(30,30,100,200)];
views.backgroundColor = [UIColor redColor];
}//3
-(void)viewWillAppear:(BOOL)animated{}//5
-(void)viewDidAppear:(BOOL)animated{}//8
-(void)viewWillDisappear:(BOOL)animated{}//9
-(void)viewDidDisappear:(BOOL)animated{}//10
- (void)viewDidLayoutSubviews{}//7 jiazaiwan
- (void)viewWillLayoutSubviews{}//6
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc
{
}
@end
```
uiviewcontroller 生命周期
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 最近有一个小师弟问我生命周期和程序执行顺序的问题,话不多少,这就分享一篇文章.非常详细. 当一个视图控制器被创建,...
- UIView+SGFrame.h #import @interface UIView (SGFrame) @pro...
- VC的生命周期是我们编程中经常用到的几个API, 特此借鉴整理 当你alloc并init了一个ViewContro...
- 1、+ (id)alloc 分配内存 2、- (id)init 方法 包括其他-(id)init...方法),只允...