我有一个 UIDatePicker
处于倒计时模式。 UIDatePicker
默认不支持自动调整大小。所以我手动设置框架以调整横向大小
- (void) resizeDatePicker: (UIInterfaceOrientation)orientation
{
if (UIInterfaceOrientationIsPortrait(orientation))
{
self.timePicker.frame = CGRectMake(0, 44, 320, 216);
}
else
{
self.timePicker.frame = CGRectMake(0, 44, 480, 162);
}
}
除倒数计时器外,它适用于所有其他模式。在倒计时模式下显示不清晰。
最佳答案
解决了我的问题。我在这里发布我的答案。可能会对其他人有所帮助。在倒数计时器模式下,您不能直接调整框架的大小。所以我将日期选择器添加为 View 的 subview ,然后将 CGAffineTransformMakeScale 应用于 View 。然后我也将框架设置到适当的位置。
if (UIInterfaceOrientationIsPortrait(orientation))
{
self.pickerView.transform = CGAffineTransformIdentity;
self.pickerView.frame =CGRectMake(0,40, 320, 216);
}
else
{
self.pickerView.transform = CGAffineTransformMakeScale(0.65, 0.65);
self.pickerView.frame =CGRectMake(0,40, 480, 140);
}
它将选择器的大小减小 65%。 PickerView 是包含选择器的 View 。
下面的问题帮我解决了这个问题
关于iphone - 倒计时模式下的 UIDatePicker 不支持调整大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14580565/