控制器的生命周期方法题及内存警告时的处理

1.图解

控制器的生命周期方法题及内存警告时的处理_第1张图片

2.方法解释

- (void)loadView
{
    //一定调用父类的方法
    [super loadView];

    //在这里实例化self.view
    //一般不重写这个方法

    SHOW_FUNC;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    SHOW_FUNC;
}


//即将显示到屏幕上
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    SHOW_FUNC;
}

//已经显示到屏幕上
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    SHOW_FUNC;
}

//即将离开屏幕,切换到其他视图控制器
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    SHOW_FUNC;
}

//已经离开当前视图控制器
- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    SHOW_FUNC;
}



//内存紧张
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

    SHOW_FUNC;
}


//view已经销毁
- (void)viewDidUnload
{
    [super viewDidUnload];
}

//view即将销毁
- (void)viewWillUnload
{
    [super viewWillUnload];
}

内存警告处理

控制器的生命周期方法题及内存警告时的处理_第2张图片

你可能感兴趣的:(iOS,UI)