IOS storyboard(控件器的 生命周期)

 

@interface NJTwoViewController ()

@end

@implementation NJTwoViewController

// 当控制器的view加载完毕就调用
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@"Two -  viewDidLoad");
}

// 控制器即将显示的时候调用
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    NSLog(@"Two -  viewWillAppear");
}

// 控制器完全显示的时候调用
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    NSLog(@"Two -  viewDidAppear");
}

// 控制器即将消失的时候调用
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    NSLog(@"Two -  viewWillDisappear");
}
// 控制器完全消失的时候调用
- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    NSLog(@"Two -  viewDidDisappear");
}
View Code

 

 

@interface NJOneViewController ()

@property (nonatomic, strong) NSArray *foods;
@end

@implementation NJOneViewController

// 当控制器的view加载完毕就调用
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@"One -  viewDidLoad");
}

// 控制器的view即将显示的时候调用
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    NSLog(@"One -  viewWillAppear");
}

// 控制器的view完全显示的时候调用
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    NSLog(@"One -  viewDidAppear");
}

// 控制器的view即将消失的时候调用
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    NSLog(@"One -  viewWillDisappear");
}
// 控制器的view完全消失的时候调用
- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    NSLog(@"One -  viewDidDisappear");
}

// 控制器的view即将销毁的时候调用
- (void)viewWillUnload
{
    [super viewWillUnload];
}
// 控制器的view完全销毁的时候调用
- (void)viewDidUnload
{
    [super viewDidUnload];
    // 清空不需要的属性
//    [self.foods release];
    self.foods = nil;
}

//- (void)setFoods:(NSArray *)foods
//{
//    if (_foods != foods) {
//        [foods release];
//        _foods = [foods retain];
//    }
//}

// 接收到内存警告的时候调用
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    // NSLog(@"One  didReceiveMemoryWarning");
}
 /**/

 

posted on 2017-03-08 16:49  守望星空  阅读(153)  评论(0编辑  收藏  举报

导航