Following on the heels of this question, I'd like to know how to remove the magic numbers in lines like:
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
or
UIDatePicker *theDatePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0.0, 44.0, 0.0, 0.0)];
pickerDateToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[aac setBounds:CGRectMake(0,0,320, 464)];
In both cases, the solutions are attempting to create a popup with space for a button + padding on top and a picker view in the bottom. My issue is that one person likes 44 and another person like 40 and on different devices with different resolution, different sizes may look better.
In English, I want to create a popup view, place a UIPickerView in the bottom and a UIToolbar on top with some type of UIButton or UISegmentedControl in the far right corner. I'd like the picker view assume its optimum representation on the designated platform .... ie: edge to edge and the toolbar to similarly take up its standard space. I'd like the segment bar or button to then be placed in a standard way in the upper far right corner - leaving some standard, reasonable amount of padding. At the very least, I wouldn't mind specifying some % padding, etc.
So specifically, these particular examples start out with y coords of 40 or 44 - and I'm sure they came from the HIG or reflect someone aesthetic of the day ... but is there a way to query a UIToolbar for its standard dimensions which would give me the height I'm actually looking for?
And these examples both set bounds on the UIActionSheet after displaying it. For the life of me, I can't figure out how to dynamically determine how tall the action sheet should be. In other words, I can't calculate the '464' or the '485' since the UIPickerView doesn't really tell me how much space it needs ... even assuming I want to start at y coord of 40.
Does that make sense? I do understand and try to leverage calls like:
[[UIScreen mainScreen] applicationFrame];
and gravitate to practices like
UIBarButtonItem *flexSpace = ...
[barItems addObject:flexSpace];
UIBarButtonItem *doneBtn = ....
[barItems addObject:doneBtn];
but in this case, I'm at a loss of how to infer, in a standard way, the sizing of the lower control, upper control and resulting parent (without all these magic numbers that came out of a static document targeting a specific device in a specific year).