uiviewcontroller 生命周期
#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
```