1

I want to display an UIDatepicker together with a Done Button for a text field. So I followed the approach provided by Paul Hunter @ https://stackoverflow.com/a/10705161/2897650. I've added an UIView, containing a Toolbar and a datepicker, to my storyboard. It has a width of 320 and a x position of 0, so it is positioned correctly on my screen. I've created a outlet connection of my UIView and assigned that to my textfield with setInputView. The problem is: The datepicker appears at a wrong position.

datepicker .

How can I fix that?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
priojewo
  • 937
  • 2
  • 11
  • 22
  • I'd recommend having the UIPickerView only be assigned as the `inputView` for your text field, and the UIToolbar be assigned as the `inputAccessoryView`. No wrapper view that contains both. – Mike Mertsock Mar 07 '14 at 21:26
  • I tried that. Seems like the background of the toolbar gets removed and it is positioned incorrectly. Could you provide a code example? This is how it looks based on your idea: http://oi61.tinypic.com/5l5r4l.jpg – priojewo Mar 07 '14 at 21:32

1 Answers1

0

I had a similar problem where a UIDatePicker or UIPickerView would appear in a position offset from the intended. This occurred for instances created through storyboard and in code. I seem to have over come this by introducing constraints, specifically a height constraint for UIPickerView.