我有一个基于导航的应用程序,并说我的根控制器 A 导致 viewController B 被推送,它有一个 UITableView 和一些带有 UITextFields 的单元格。
前 2 个 UITextField 分别有一个 UIDatePicker 和一个 UIPickerView 作为它们的 inputView。此外,UIPickerView 有 4 个组件,其 UIViews 通过返回
- (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;
}
在垂直方向上,UIPickerView 如下所示:
我注意到以下内容:
案例 1 - 正确
- 我在垂直方向的 viewController A 中。
- 我将设备/模拟器从垂直方向旋转到水平方向
- 我推 viewController B
- 我导致 UIPickerView 弹出
选择器框架正确拉伸到横向模式,组件视图仍然是正确的大小并居中:
但
案例 2 - 不正确
- 我在垂直方向的 viewController A 中。
- 我推 viewController B
- 我将设备/模拟器从垂直方向旋转到水平方向
- 我导致 UIPickerView 弹出
在这种情况下,UIPickerView 的组件会变得混乱:
有什么想法吗?