I am looking to resize a UIPickerView / UIDatePickerView's height to 162 when my app is in landscape view. Is there an easy way to do this in auto layout in code?
I am currently trying the following method of handling the resize:
- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
NSInteger height = 216;
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
height = 162;
}
datePicker.bounds =
CGRectMake(datePicker.frame.origin.x, datePicker.frame.origin.x,
datePicker.frame.size.width, height);
}
But when this code executes in the landscape orientation, I get the following effect where the picker is not bound to the bottom left of the screen anymore (this is the white margin that appears below it):
Is there a way or auto layout to handle this resizing with UIPickerViews, or should I just play around with the bounding rectangle during one of the view rotation methods in my view controller?