视图的生命周期(代码创建时)

视图的生命周期(代码创建时)
@interface CZMainViewController ()
@property (nonatomic, weak) UIButton *myButton;
@property (nonatomic, strong) NSMutableArray *dataList; 
@end

@implementation CZMainViewController
- (NSMutableArray *)dataList {
  if (!_dataList) {
    _dataList = [NSMutableArray array];
  }
  return _dataList;
}
// NSObject         
- (instancetype)init
{
  self = [super init]; if (self) {
       NSLog(@"%s", __func__);
    }
  return self;
 }
//      “  ”      
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
  if (self) {
       NSLog(@"%s", __func__);
   }
  return self; 
}

/**
*   Storyboard *
*  iOS7               
1>  loadView         
2>  viewWillLayoutSubviews                                      
*/
- (void)loadView
{
  NSLog(@"%s", __func__); self.view = [[UIView alloc] init];
  NSLog(@"%@", NSStringFromCGRect(self.view.frame));
  UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
  [self.view addSubview:btn]; self.myButton = btn;
  [btn addTarget:self action:@selector(click)           forControlEvents:UIControlEventTouchUpInside];   
 }

- (void)click
{
  CZDetailViewController *vc = [[CZDetailViewController alloc] init];               [self.navigationController pushViewController:vc animated:YES];
}
/**
*            */
- (void)viewDidLoad
{
  [super viewDidLoad];
   NSLog(@"%s", __func__);
    NSLog(@"%@", self.view.superview); 
}


/**
*             */
- (void)viewWillAppear:(BOOL)animated
{
   NSLog(@"%s", __func__); LogFrame(self.view); NSLog(@"%@", self.view);
}
/**
*             */
- (void)viewDidAppear:(BOOL)animated
{
   NSLog(@"%s", __func__);
}

/**
*         */
- (void)viewWillLayoutSubviews
{
   NSLog(@"%s", __func__);
   self.myButton.center = self.view.center;
 }

// layoutSubViews      UIView  
/**
*         */
- (void)viewDidLayoutSubviews
{
}

/**
*        */
- (void)viewWillDisappear:(BOOL)animated
{
   NSLog(@"%s", __func__);
}
/**
*      */
- (void)viewDidDisappear:(BOOL)animated
{
   NSLog(@"%s", __func__);
}
/**
*        
*/
- (void)didReceiveMemoryWarning
{
//      "   "         [super didReceiveMemoryWarning];
//                       
//                      
//   isViewLoaded                              
  if (!self.isViewLoaded) {
    self.dataList = nil;
   }
}

- (void)dealloc
{
   NSLog(@"%s", __func__);
}


// iOS5           
 - (void)viewWillUnload
{
  NSLog(@"%s", __func__); [super viewWillUnload];
}

- (void)viewDidUnload
{
  NSLog(@"%s", __func__); [super viewDidUnload];
 }

你可能感兴趣的:(视图的生命周期(代码创建时))