UIDatePicker not rendering properly for certain modes in UIPopoverController

こ雲淡風輕ζ 提交于 2019-12-11 04:58:29

问题


I have a UIDatePicker using UIDatePickerModeTime that I use in an iPhone app modally, works fine:

Using this same basic code for iPad, but putting the view in a UIPopoverController gives some pretty inconsistent results. My desired mode (UIDatePickerModeTime) plus the other three modes are shown below. Notice how 2 of them are not rendering at all, but instead have no content

UIDatePickerModeTime

UIDatePickerModeCountDownTimer

UIDatePickerModeDateAndTime

UIDatePickerModeDate

What could be causing the UIDatePickerModeTime and UIDatePickerModeDateAndTime modes to go haywire?


回答1:


Instantiating the UIDatePicker with CGRectZero was the culprit. Even though the code worked on iPhone, and I call sizeToFit explicitly on it to set the size, changing the CGRectZero to CGRectMake(0,0,320,160) was what got it to display. Go figure.



来源:https://stackoverflow.com/questions/4025367/uidatepicker-not-rendering-properly-for-certain-modes-in-uipopovercontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!