I am changing the code from the XIB to the storyboard. Apparently, there is a significant difference in the timing of setting frames for the borders of the subbands of the storyboard scene.
The method that this code often uses is this:
- The UIView subview has dimensions defined in the XIB file or storyboard (allowing someone other than the programmer to change the user interface)
- UIViewController has an object reference as an
IBObject UIView * - in UIViewController
- viewWillAppear() , certain calculations are performed and performed based on these calculations.
For example, in our XIB or Storyboard file there is a UIView that we want to cut into four areas. The controller looks at the borders of this UIView, looks at its frame, and then draws four windows in the UIView, each one size.
In .h:
IBOutlet UIView *outputColorKeyView;
In .m viewWillAppear :
CGRect keyBounds = [outputColorKeyView bounds]; float high = keyBounds.size.height; float wide = keyBounds.size.width; float cellWidth = wide/4.0; XLog(@"Dimensions for the color key are: %f %f", high, wide);
My problem is that in XIB this worked fine: I was able to see that the dimensions of the area I was supposed to draw were 200 points (for example), and the cells could be drawn at 50 points.
In the Storyboards section, this no longer works for me: I get a frame (0,0,0,0) when I call the viewWillAppear method from the controller:
[18:09:16.901|4096] Dimensions for the color key are: 0.000000 0.000000
However, run later in the program life cycle (launched by the button), I get the correct result:
[18:09:35.812|4096] Dimensions for the color key are: 36.000000 734.000000
Is there any way to get this information before the presentation? I would have thought so, but viewWillAppear seems like the last opportunity before the views actually display. Or is there some kind of obvious switch that I donβt have enough for this equipment to work as intended?
thanks