티스토리 뷰

iOS 개발/iOS

ViewController LifeCycle

beankhan 2016. 7. 24. 14:26
ViewController LifeCycle

- (void)viewDidLoad {
    [
super viewDidLoad];
   
NSLog(@"viewDidLoad");
}

- (
void)viewWillAppear:(BOOL)animated {
    [
super viewWillAppear:animated];
   
NSLog(@"viewWillAppear");
}

- (
void)viewWillLayoutSubviews {
    [
super viewWillLayoutSubviews];
   
NSLog(@"viewWillLayoutSubviews");
}

- (
void)viewDidLayoutSubviews {
    [
super viewDidLayoutSubviews];
   
NSLog(@"viewDidLayoutSubviews");
}

- (
void)viewDidAppear:(BOOL)animated {
    [
super viewDidAppear:animated];
   
NSLog(@"viewDidAppear");
}

- (
void)viewDidDisappear:(BOOL)animated {
    [
super viewDidDisappear:animated];
   
NSLog(@"viewDidDisappear");
}

- (
void)viewWillDisappear:(BOOL)animated {
    [
super viewWillDisappear:animated];
   
NSLog(@"viewWillDisappear");
}

- (
void)dealloc {
   
NSLog(@"dealloc");
}

2016-05-05 11:40:07.190 test[1286:85451] viewWillDisappear <SKTPDevSettingViewController: 0x7fd1e6042310>
2016-05-05 11:40:07.191 test[1286:85451] viewDidLoad
2016-05-05 11:40:07.192 test[1286:85451] viewWillAppear
2016-05-05 11:40:07.194 test[1286:85451] viewWillLayoutSubviews
2016-05-05 11:40:07.194 test[1286:85451] viewDidLayoutSubviews
2016-05-05 11:40:07.697 test[1286:85451] viewDidDisappear <SKTPDevSettingViewController: 0x7fd1e6042310>
2016-05-05 11:40:07.697 test[1286:85451] viewDidAppear

2016-05-05 11:41:09.691 test[1286:85451] viewWillDisappear
2016-05-05 11:41:09.691 test[1286:85451] viewWillAppear <SKTPDevSettingViewController: 0x7fd1e6042310> 
=== (Back 버튼으로 VC 가 중간에 걸쳐있을 때 여기까지 호출) ==

2016-05-05 11:41:12.394 test[1286:85451] viewDidDisappear
2016-05-05 11:41:12.394 test[1286:85451] viewDidAppear <SKTPDevSettingViewController: 0x7fd1e6042310>
2016-05-05 11:41:12.394 test[1286:85451] dealloc




ViewController LifeCycle 상세 

1. initWithCoder:
     When using storyboards, the controller is initialized with this method, not with the init or initWithNibName:bundle: methods.
2. awakeFromNib
3. willMoveToParentViewController:
     The controller that is passed with this call is the UINavigationController.
4. prefersStatusBarHidden
5. preferredStatusBarUpdateAnimation
6. loadView
     UIViewController‘s loadView function assigns all objects with ‘Referencing Outlets’ (aka IBOutlets) in Interface Builder to their corresponding IBOutlet properties. If you need access to these IBOutlet objects in this function, call super first.
7. prepareForSegue:sender:
     This call allows us to inspect the UIStoryboardEmbedSegue that embeds the smaller scene in Scene B’s container view.
8. viewDidLoad
     This method is usually where most of a controller’s set up happens. Note that all of our IBOutlets have been connected, but our views have not yet been laid out.
9. extendedLayoutIncludesOpaqueBars
10. edgesForExtendedLayout
11. viewWillAppear:
12. extendedLayoutIncludesOpaqueBars
13. edgesForExtendedLayout
14. updateViewConstraints
15. viewWillLayoutSubviews
16. viewDidLayoutSubviews
17. Animation
     The animation that transitions from Scene A to Scene B runs. Step 18 does not happen until the animation finishes.
18. viewDidAppear:
19. didMoveToParentViewController:
     This call concludes the process started on step 2. Here we receive the same instance of UINavigationController.
20. updateViewConstraints
21. viewWillLayoutSubviews
22. viewDidLayoutSubviews





View Controller 에서 실제 사이즈가 잡히는 시간 테스트 결과값

- (void)viewDidLoad {
    [
super viewDidLoad];
   
NSLog(@"viewDidLoad : (%f, %f, %f, %f)", _testView.frame.origin.x, _testView.frame.origin.y, _testView.frame.size.width, _testView.frame.size.height);
}

- (
void)viewWillAppear:(BOOL)animated {
    [
super viewWillAppear:animated];
   
NSLog(@"viewWillAppear : (%f, %f, %f, %f)", _testView.frame.origin.x, _testView.frame.origin.y, _testView.frame.size.width, _testView.frame.size.height);
}

- (
void)viewWillLayoutSubviews {
    [
super viewWillLayoutSubviews];
   
NSLog(@"viewWillLayoutSubviews : (%f, %f, %f, %f)", _testView.frame.origin.x, _testView.frame.origin.y, _testView.frame.size.width, _testView.frame.size.height);
}

- (
void)viewDidLayoutSubviews {
    [
super viewDidLayoutSubviews];
   
NSLog(@"viewDidLayoutSubviews : (%f, %f, %f, %f)", _testView.frame.origin.x, _testView.frame.origin.y, _testView.frame.size.width, _testView.frame.size.height);
}

- (
void)viewDidAppear:(BOOL)animated {
    [
super viewDidAppear:animated];
   
NSLog(@"viewDidAppear : (%f, %f, %f, %f)", _testView.frame.origin.x, _testView.frame.origin.y, _testView.frame.size.width, _testView.frame.size.height);
}

- (
void)viewDidDisappear:(BOOL)animated {
    [
super viewDidDisappear:animated];
   
NSLog(@"viewDidDisappear : (%f, %f, %f, %f)", _testView.frame.origin.x, _testView.frame.origin.y, _testView.frame.size.width, _testView.frame.size.height);
}

- (
void)viewWillDisappear:(BOOL)animated {
    [
super viewWillDisappear:animated];
    NSLog(@"viewWillDisappear : (%f, %f, %f, %f)", _testView.frame.origin.x, _testView.frame.origin.y, _testView.frame.size.width, _testView.frame.size.height);
}

2016-05-05 11:50:16.715 test[2093:158423] viewWillDisappear <SKTPDevSettingViewController: 0x7f8cc27f13b0>
2016-05-05 11:50:16.725 test[2093:158423] viewDidLoad : (40.000000, 131.000000, 240.000000, 128.000000)
2016-05-05 11:50:16.725 test[2093:158423] viewWillAppear : (40.000000, 131.000000, 240.000000, 128.000000)
2016-05-05 11:50:16.728 test[2093:158423] viewWillLayoutSubviews : (40.000000, 131.000000, 240.000000, 128.000000)

2016-05-05 11:50:16.728 test[2093:158423] viewDidLayoutSubviews : (40.000000, 131.000000, 334.000000, 128.000000)
2016-05-05 11:50:17.231 test[2093:158423] viewDidDisappear <SKTPDevSettingViewController: 0x7f8cc27f13b0>
2016-05-05 11:50:17.232 test[2093:158423] viewDidAppear : (40.000000, 131.000000, 334.000000, 128.000000)
2016-05-05 11:50:17.232 test[2093:158423] viewWillLayoutSubviews : (40.000000, 131.000000, 334.000000, 128.000000)
2016-05-05 11:50:17.232 test[2093:158423] viewDidLayoutSubviews : (40.000000, 131.000000, 334.000000, 128.000000)





참고자료


https://bradbambara.wordpress.com/2014/07/31/object-life-cycle-uiviewcontroller/


'iOS 개발 > iOS' 카테고리의 다른 글

iPhone 초기화, Simulator Path, Sandbox 추출  (0) 2016.07.24
UIView LifeCycle  (0) 2016.07.24
Application LifeCycle  (0) 2016.07.24
int, NSInteger, NSNumber의 차이  (0) 2016.07.24
UIResponder  (0) 2016.07.24
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함