ViewController启动加载过程

 ViewController加载过程(ShowViewCycle是ViewController.view的subView):

1. -[ViewController initWithNibName:bundle:] [Line 82] nibNameOrNil:(null), nibBundleOrNil:(null)

  ViewController初始化方法

    参数nibBundleOrNil:指定nib文件搜索的bundle,默认位mainBundle

    参数nibNameOrNil:指定nib文件的名称,如果不指定,则先搜索View.nib,再搜索 ViewController.nib

2. -[ViewController loadView] [Line 100] 

  在self.view==nil的条件下调用 

  2.1 -[ViewController willMoveToParentViewController:] [Line 363] 

  2.2 -[ShowViewCycle initWithFrame:] [Line 49] 

  2.3 -[ShowViewCycle setNeedsDisplay] [Line 259] 

    ShowViewCycle的属性改变都会触发setNeedsDisplay

  2.4 -[ShowViewCycle setNeedsDisplay] [Line 259] 

  2.5 -[ShowViewCycle setNeedsDisplay] [Line 259] 

  2.6 -[ShowViewCycle willMoveToSuperview:] [Line 174] 

  2.7 -[ShowViewCycle didMoveToSuperview] [Line 181] 

  2.8 -[ShowViewCycle setTranslatesAutoresizingMaskIntoConstraints:] 

    mas_makeConstraints主动触发

  2.9 -[ShowViewCycle isDescendantOfView:] [Line 200]

    addConstraint,会触发该判定,判定一个view是否是另一个view的subview

  2.10-[ShowViewCycle isDescendantOfView:] [Line 200] 

  2.11-[ShowViewCycle isDescendantOfView:] [Line 200] 

  2.12-[ShowViewCycle isDescendantOfView:] [Line 200] 

3. -[ViewController viewDidLoad] [Line 107] 

  3.1 -[ViewController shouldAutomaticallyForwardAppearanceMethods] [Line 336] 

  返回值如果是NO,子类必须重写- viewWillAppear: -viewDidAppear: -viewWillDisappear: -viewDidDisappear: -willRotateToInterfaceOrientation:duration:  -willAnimateRotationToInterfaceOrientation:duration: -didRotateFromInterfaceOrientation:方法

4. -[ViewController viewWillAppear:] [Line 159] 

  4.1 -[ViewController beginAppearanceTransition:animated:] [Line 298] 

  4.2 -[ViewController shouldAutomaticallyForwardAppearanceMethods] [Line 336] 

  4.3 -[ShowViewCycle willMoveToWindow:] [Line 188] 

  4.4 -[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.5 -[ShowViewCycle needsUpdateConstraints] [Line 375] 

  4.6 -[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.7 -[ShowViewCycle isDescendantOfView:] 

  4.8 -[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.9 -[ShowViewCycle isDescendantOfView:] [Line 200] 

  4.10-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.11-[ShowViewCycle isDescendantOfView:] [Line 200] 

  4.12-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.13-[ShowViewCycle isDescendantOfView:] [Line 200] 

  4.14-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.15-[ShowViewCycle didMoveToWindow] [Line 195] 

  4.16-[ViewController viewWillLayoutSubviews] [Line 188] 

  4.17-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.18-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.19-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.20-[ShowViewCycle intrinsicContentSize] [Line 451] 

      内在内容的大小

  4.21-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.22-[ShowViewCycle updateConstraints] [Line 370]   

  4.23-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.24-[ShowViewCycle alignmentRectInsets] [Line 434] 

  4.25-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.26-[ShowViewCycle alignmentRectInsets] [Line 434]   

  4.27-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.28-[ShowViewCycle alignmentRectInsets] [Line 434] 

  4.29-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393]   

  4.30-[ShowViewCycle alignmentRectInsets] [Line 434] 

  4.31-[ViewController updateViewConstraints] [Line 387] 

  4.32-[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  4.33-[ShowViewCycle alignmentRectInsets] [Line 434] 

  4.34-[ViewController viewDidLayoutSubviews] [Line 196] 

  4.35-[ShowViewCycle layoutSubviews] [Line 231] 

  4.36-[ShowViewCycle drawRect:] [Line 252] 

  4.37-[ViewController shouldAutomaticallyForwardAppearanceMethods] [Line 336] 

5. -[ViewController viewDidAppear:] [Line 166] 

  5.1 -[ViewController didMoveToParentViewController:] [Line 370] 

  5.2 -[ViewController viewWillLayoutSubviews] [Line 188] 

  5.3 -[ViewController updateViewConstraints] [Line 387] 

  5.4 -[ShowViewCycle translatesAutoresizingMaskIntoConstraints] [Line 393] 

  5.5 -[ShowViewCycle alignmentRectInsets] [Line 434] 

  5.6 -[ViewController viewDidLayoutSubviews] [Line 196] 

原文地址:https://www.cnblogs.com/StarMud/p/4597215.html