There is a related issue that I am forced to turn to, which I hope will save someone else on the debugging day:
I find out that in the storyboard:
segue-push does not cause subView to be placed in -viewDidLayoutSubviews (instead, they are laid out at other times before -viewDidAppear ).
While ...segue-modal and [navController.storyboard presentViewController:] makes the cause of subViews to be placed in -viewDidLayoutSubviews .
The solution is to put [self.mySubView layoutSubviews] in the viewController -viewDidLayoutSubviews method to manually load the subView inside mySubView .
My thing was that I had a special gradient button that incorrectly initialized the visual appearance.
The button was contained in a scrollView containing a CustomView that contained a custom gradient button.
So basically ... a view button inside scrollView .
The application starts with UINavigationController with loading another ViewController1 .
ViewController1 contains a button that, when clicked, launches the segue-push storyboard on ViewController2 .
(this was organized in a storyboard, controlling the drag and drop from a button in ViewController1 to ViewController2 ).
ViewController2 contains scrollView / CustomView / customButton .
In ViewController2 -viewDidLayoutSubviews I initialize customButton , which is a custom Gradient button that has its own .h / .m files.
GradientButton.m has an initLayers method that configures it graphically and requires that the bounds / frame property of the button be initialized.
However ...
in ViewController2 -viewDidLayoutSubviews , self.customButton had a frame of 0,0,0,0.
A few notes:
- Yes, I call
[super viewDidLayoutSubviews] at the beginning of -viewDidLayoutSubviews . - The only view that has been outlined in
-viewDidLayoutSubviews is self.view ( ViewController2 initial view linked in the Storyboard connections panel). In my case - self.view - scrollView ).
To solve:
- in
ViewController2 , I created a self.bottomView output for a view containing self.customButton . - in
ViewController2 -viewDidLayoutSubviews , I call [self.bottomView layoutSubviews]- This will cause the
customButton frame / borders to customButton .
- Then I call
[self.customButton initLayers] , which now correctly initializes my custom gradient button.
A few notes about ViewController2 -viewDidLayoutSubviews: calling [self.view layoutSubviews] trigger a bottomView frame, but NOT a customButton . In terms of the view hierarchy, -layoutSubviews applies only to subView self.view , and not to any subView these subView s.
This is similar to the segue-push storyboard.
The segue-modal storyboard and the software [navController presentViewController] both seem correctly initialized by all levels of the view hierarchy (all " subView of subView s") by the time -viewDidLayoutSubviews .
source share