Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a UIDatePicker as an inputView to a textField in iOS 8

I have an UIDatePicker in my storyboard view connected to an IBOutlet in the header file.

In the implementation file I set some properties to the picker and then assign it to my textFields:

[self.txtEndDate setInputView:self.picker];

This was working fine in iOS 7, but with iOS 8 it's giving me the following error:

Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<UICompatibilityInputViewController: 0x7c2d8800> should have parent view controller:<InserimentoDurata: 0x7aec2b10> but requested parent is:<UIInputWindowController: 0x7b92b400>'

Any idea on how to fix this?

like image 980
Aleph72 Avatar asked Sep 20 '14 16:09

Aleph72


1 Answers

After receiving an email from Apple's Developer Technical Support, it seems that to add a UIDatePicker (or any custom keyboard for what I've understood) to a viewController, you don't have to add it to its view anymore, but you add it to its title bar and then connect it to the IBOutlet.

It's working for me, even if it doesn't work in the iPhone 5 simulator (all the others are ok) and I was going nuts.

I hope this could be of help for other people with the same problem.

like image 128
Aleph72 Avatar answered Sep 27 '22 00:09

Aleph72