2013-01-03

Size of UIViews throughout startup.

Looking again at this iPad container-VC-plus-two-content-VCs storyboard setup:

In the Storyboard, the size of ZetaView is 768 × 669 and MuView is 768 × 338. Suppose you need to perform calculations on these numbers at some point while your app is starting up. Those views are not always those dimensions at every phase of start up. These logs show you.

2013-01-03 11:23:07.588 Sandbox[11233:11303] -[SBAppDelegate application:didFinishLaunchingWithOptions:] [Line 16] Entered here.
2013-01-03 11:23:07.593 Sandbox[11233:11303] -[SBContainerViewController prepareForSegue:sender:] [Line 76] childViewController count = 0
2013-01-03 11:23:07.596 Sandbox[11233:11303] -[SBContainerViewController prepareForSegue:sender:] [Line 78] Fired segue = ZetaSegue
2013-01-03 11:23:07.626 Sandbox[11233:11303] -[SBZetaViewController viewDidLoad] [Line 37] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.627 Sandbox[11233:11303] -[SBZetaViewController viewDidLoad] [Line 38] self.view.frame.size.height = 1004.000000
2013-01-03 11:23:07.628 Sandbox[11233:11303] -[SBContainerViewController prepareForSegue:sender:] [Line 76] childViewController count = 1
2013-01-03 11:23:07.628 Sandbox[11233:11303] -[SBContainerViewController prepareForSegue:sender:] [Line 78] Fired segue = MuSegue
2013-01-03 11:23:07.630 Sandbox[11233:11303] -[SBMuViewController viewDidLoad] [Line 37] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.630 Sandbox[11233:11303] -[SBMuViewController viewDidLoad] [Line 38] self.view.frame.size.height = 1004.000000
2013-01-03 11:23:07.631 Sandbox[11233:11303] -[SBContainerViewController viewDidLoad] [Line 37] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.738 Sandbox[11233:11303] -[SBContainerViewController viewDidLoad] [Line 38] self.view.frame.size.height = 1004.000000
2013-01-03 11:23:07.739 Sandbox[11233:11303] -[SBContainerViewController viewWillAppear:] [Line 46] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.740 Sandbox[11233:11303] -[SBContainerViewController viewWillAppear:] [Line 47] self.view.frame.size.height = 1004.000000
2013-01-03 11:23:07.741 Sandbox[11233:11303] -[SBZetaViewController viewWillAppear:] [Line 46] self.view.frame.size.width = 0.000000
2013-01-03 11:23:07.741 Sandbox[11233:11303] -[SBZetaViewController viewWillAppear:] [Line 47] self.view.frame.size.height = 0.000000
2013-01-03 11:23:07.742 Sandbox[11233:11303] -[SBMuViewController viewWillAppear:] [Line 46] self.view.frame.size.width = 0.000000
2013-01-03 11:23:07.742 Sandbox[11233:11303] -[SBMuViewController viewWillAppear:] [Line 47] self.view.frame.size.height = 0.000000
2013-01-03 11:23:07.748 Sandbox[11233:11303] -[SBContainerViewController viewWillLayoutSubviews] [Line 62] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.749 Sandbox[11233:11303] -[SBContainerViewController viewWillLayoutSubviews] [Line 63] self.view.frame.size.height = 1004.000000
2013-01-03 11:23:07.750 Sandbox[11233:11303] -[SBContainerViewController viewDidLayoutSubviews] [Line 69] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.751 Sandbox[11233:11303] -[SBContainerViewController viewDidLayoutSubviews] [Line 70] self.view.frame.size.height = 1004.000000
2013-01-03 11:23:07.752 Sandbox[11233:11303] -[SBMuViewController viewWillLayoutSubviews] [Line 62] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.753 Sandbox[11233:11303] -[SBMuViewController viewWillLayoutSubviews] [Line 63] self.view.frame.size.height = 338.000000
2013-01-03 11:23:07.754 Sandbox[11233:11303] -[SBMuViewController viewDidLayoutSubviews] [Line 69] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.755 Sandbox[11233:11303] -[SBMuViewController viewDidLayoutSubviews] [Line 70] self.view.frame.size.height = 338.000000
2013-01-03 11:23:07.756 Sandbox[11233:11303] -[SBZetaViewController viewWillLayoutSubviews] [Line 62] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.757 Sandbox[11233:11303] -[SBZetaViewController viewWillLayoutSubviews] [Line 63] self.view.frame.size.height = 669.000000
2013-01-03 11:23:07.758 Sandbox[11233:11303] -[SBZetaViewController viewDidLayoutSubviews] [Line 69] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.759 Sandbox[11233:11303] -[SBZetaViewController viewDidLayoutSubviews] [Line 70] self.view.frame.size.height = 669.000000
2013-01-03 11:23:07.760 Sandbox[11233:11303] -[SBMuViewController viewWillLayoutSubviews] [Line 62] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.761 Sandbox[11233:11303] -[SBMuViewController viewWillLayoutSubviews] [Line 63] self.view.frame.size.height = 338.000000
2013-01-03 11:23:07.761 Sandbox[11233:11303] -[SBMuViewController viewDidLayoutSubviews] [Line 69] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.762 Sandbox[11233:11303] -[SBMuViewController viewDidLayoutSubviews] [Line 70] self.view.frame.size.height = 338.000000
2013-01-03 11:23:07.763 Sandbox[11233:11303] -[SBZetaViewController viewWillLayoutSubviews] [Line 62] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.764 Sandbox[11233:11303] -[SBZetaViewController viewWillLayoutSubviews] [Line 63] self.view.frame.size.height = 669.000000
2013-01-03 11:23:07.765 Sandbox[11233:11303] -[SBZetaViewController viewDidLayoutSubviews] [Line 69] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.765 Sandbox[11233:11303] -[SBZetaViewController viewDidLayoutSubviews] [Line 70] self.view.frame.size.height = 669.000000
2013-01-03 11:23:07.768 Sandbox[11233:11303] -[SBAppDelegate application:didFinishLaunchingWithOptions:] [Line 20] Done here.
2013-01-03 11:23:07.772 Sandbox[11233:11303] -[SBContainerViewController viewDidAppear:] [Line 55] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.773 Sandbox[11233:11303] -[SBContainerViewController viewDidAppear:] [Line 56] self.view.frame.size.height = 1004.000000
2013-01-03 11:23:07.774 Sandbox[11233:11303] -[SBZetaViewController viewDidAppear:] [Line 55] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.775 Sandbox[11233:11303] -[SBZetaViewController viewDidAppear:] [Line 56] self.view.frame.size.height = 669.000000
2013-01-03 11:23:07.776 Sandbox[11233:11303] -[SBMuViewController viewDidAppear:] [Line 55] self.view.frame.size.width = 768.000000
2013-01-03 11:23:07.777 Sandbox[11233:11303] -[SBMuViewController viewDidAppear:] [Line 56] self.view.frame.size.height = 338.000000

Take a look at the journey MuView goes through. It starts off full screen in viewDidLoad. Then it becomes 0 × 0 in viewWillAppear.  The first time it has the correct size is in viewWillLayoutSubviews.

But again, keep in mind that viewWillLayoutSubviews can get called frequently during a running app.

No comments:

Post a Comment