美文网首页
uiviewcontroller 生命周期

uiviewcontroller 生命周期

作者: 加嘞个油seek | 来源:发表于2018-04-16 22:05 被阅读0次

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

          本文链接:https://www.haomeiwen.com/subject/minfettx.html