My app is suddenly unable to correctly display UIDatePickers. I'm using storyboards. The Datepickers are set to just display the date. They are cutting off the month, and also not even showing the days. There's a big space in the middle. I have tried cleaning the project, resetting the simulator, checking localization settings, and checking to see if dynamic type size was set. I'm using Xcode 5.1.1 but the same thing happens in the beta of Xcode 6. Any suggestions would be appreciated.
Asked
Active
Viewed 3,847 times
10
-
Exact same behavior. But I currently experiencing this only if keyboard is en_US and when I use iOS 8 on iPad. The same settings are working for iPhone or another language (de_de). Currently there is a bug on iOS 8.1.1/Xcode 6.1.1 in iOS Simulator so I can't test another language here. – testing Dec 04 '14 at 09:01
-
Now I filled out a bug report after my test project showed the same issue. – testing Dec 04 '14 at 10:08
-
Can you reproduce the problem in a scratch project? – SmileBot Dec 04 '14 at 18:30
-
1Very easily. Place a `UIDatePicker` into a static `UITableViewCell`, set it to date format only and start one iPad simulator. I made a test project [here](http://www46.zippyshare.com/v/82755369/file.html). This happened on iOS 8.1 and iOS 8.1.1. iOS 7 is working fine. – testing Dec 04 '14 at 19:49
-
2Ok, I fixed it. Just use auto layout and set the top, sides and bottom of the picker to the cell container and it fixes the issue. I would still report it. here's the file fixed http://www72.zippyshare.com/v/3974396/file.html – SmileBot Dec 04 '14 at 20:20
-
Already reported. In my project I used the following constraints: centerX, centerY, height, width. That works on iPhone but not on iPad. Do you get it working with centering constraints or do I need to pin it to the sides? – testing Dec 04 '14 at 20:57
-
I just ran it in the iPad simulator. I didn't use centerX or Y. I just pinned it to the sides. But experiment around. It cleared up the problem in the iPad simulator for me with the top, bottom, right and left. But I'm not sure if that's what you needed. – SmileBot Dec 05 '14 at 01:21
-
I just encountered the same sort of issue. My UIDatePicker is place in a static UITableViewCell. The UITableView is displayed in a Modal (not full screen). Default behavior seems to resize the UIViews (including the UIDatePicker) as the Modal is presented. I have tried pinning it to the edges but the dates are still cut. However, the separators DO extend to the edges…Looks like a bug to me. – Benjamin Feb 25 '15 at 15:28
-
I have date pickers working inside static table view cells without any issues and they're modals; in fact I have them appearing in pop ups using custom transitions. Are you using auto layout? – SmileBot Feb 25 '15 at 21:27
-
@smileBot Thank you! I had the constraints set to the cell's content view (-8), but changing the constraints to the cell itself did the trick. – blwinters Oct 04 '15 at 03:20
-
Check this answer : http://stackoverflow.com/a/33088714 worked for me. – Krishna Shanbhag Dec 18 '15 at 10:55
2 Answers
2
Ok, I figured it out. This happened as a result of trying to use UIAppearance on a tableView background color. This has nothing to do with tableViews on the face of it, but Apple must be using a tableView privately for the PickerViews. So, my attempt to set a UIAppearance via a category on a tableView background color seems to be doing something unexpected. Lesson learned. Don't try to use UIAppearance where they are not officially supported.

SmileBot
- 19,393
- 7
- 65
- 62
-
Exact same behaviour - except I don't use UIAppearance. UIDatePicker just sits inside a UITableViewCell. I have exact same setup in different UITableView, where it is working. – pawi Oct 20 '14 at 13:54
-
Are both tableViews the same type? It seems the picker is likely some kind of scrollable tableView. But if you have it working in one place and not another then there must be a difference of some kind. I would look at the tableView types and then look at the font settings for the cells, since this might be getting picked up by the picker somehow. Post back when you solve it. I'm curious to know what it turns out to be. – SmileBot Oct 20 '14 at 14:21
-
2I'm experiencing this same issue, only on iPad, with a `UIDatePicker` inside a cell. I had some `UIAppearance` stuff but not on `UITableView`, I removed them all to test, and the issue has persisted. I'm also not touching the `backgroundColor` of the table view, it's default white. – Luke Jan 05 '15 at 13:00
-
@lukech Make sure you turn off UIAppearance for everything to test, especially any scroll views. The other thing to look at is the intrinsic content size of the picker, which the cell might be overriding. I'm just guessing since I have not encountered this issue. Post back when you solve it. – SmileBot Jan 05 '15 at 17:51
0
I had this exact same issue, and it was related to duplicate constraints in my storyboard. I'd been implementing iPhone 6 widths and inadvertently ended up with both width = 320
and width >= 320
. Removing that width = 320
fixed it instantly.

Luke
- 9,512
- 15
- 82
- 146