I have a configuration UITableView that can launch a colour picker via a UINavigationController approach:
[self.navigationController pushViewController:colorPickerViewController animated:YES];
[colorPickerViewController release];
The effect of this means the ColourPicker will have a navigation bar at the top ( and back button)
The structure of the ColourPickerViewControll and it view ColourPickerView is as follows:
- ColourPickerViewController - in it's XIB file at the top level view it has:
- ColorPickerView : UIView (i.e. custom UI view) - in it's methods it has:
- (id)initWithCoder:(NSCoder*)coder {
if ((self = [super initWithCoder:coder])) {
CGFloat currVertBounds = self.bounds.size.height;
The issue here is the the value of currVertBounds is coming to 480, so it’s not taking account of the navigation bar
QUESTION: How do I get the true displayed height of the ColorPickerView instance?
Is it something to do with trying to get the layout calculated in the custom UIView, and perhaps the custom view isn’t rendered within the overall controll/navigationController at that stage?
You’re reading
boundstoo early. None of the layout/subviewing magic that happens inUIKitwill take place during[super initWithCoder:]. You should be readingboundsand laying out your view either:viewDidLoad/viewWillAppear, and set up the autosizing parameters for all manually created UI elements so they can get moved around with respect to different interface orientations. In these functions I wouldn’t rely onboundsbeing exactly correct but I would say it’s at least the right height:width ratio. It could possibly be in the wrong orientation, though.viewDidAppear, if you wish to manually position elements. By the time you hitviewDidAppearall of the resizing and such has taken place, and the only thing left to worry about is future rotations, which you should adjust your view for inwillAnimateRotationToInterfaceOrientation:duration:.Docs on
willAnimateRotationToInterfaceOrientation:duration:state:iOS 5.0 docs add the clause:
…set to the new orientation , and the bounds of the view have been changed. Thus…
I think this is still the case for prior iOS versions.