I have a navigation-based app and say my root controller A causes a viewController B to be pushed, which has a UITableView with a few cells with UITextFields.
The first 2 UITextFields have each, as their inputView, a UIDatePicker and a UIPickerView, respectively. Also, the UIPickerView has 4 components whose UIViews are returned through
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 37)];
label.text = [NSString stringWithFormat:@"%@%i", ((component == 3) ? @"." : @""), row];
label.textAlignment = UITextAlignmentCenter;
label.font = [UIFont boldSystemFontOfSize:24];
label.backgroundColor = [UIColor clearColor];
[label autorelease];
return label;
}
In vertical orientation, the UIPickerView looks like this:
What I've noticed is the following:
CASE 1 - CORRECT
- I'm in viewController A in vertical orientation.
- I rotate the device / simulator from a vertical orientation to horizontal orientation
- I push viewController B
- I cause the UIPickerView to pop up
The picker frame is correctly stretched to landscape mode and the component views are still the correct size and centered:
BUT
CASE 2 - INCORRECT
- I'm in viewController A in vertical orientation.
- I push viewController B
- I rotate the device / simulator from a vertical orientation to horizontal orientation
- I cause the UIPickerView to pop up
In this case, the UIPickerView's components get messed up:
Any thoughts?