Show UIDatePicker inside UIPopoverController after UIKeyboard is dismissed?

Up vote 1 down vote favorite share g+ share fb share tw.

I am pulling my hair out with this one. I have a table inside a popover which allows the user to edit some data. Most of these editable cells need the user to enter data via the keyboard, but one needs a UIDatePicker.

When the UIDatePicker is presented to the user, it slides in from the bottom of the popover by grabbing the size of the view and performing an animation. However, if this happens after the keyboard is dismissed then the size of the view is grabbed before the popover is reset back its original position (i.e. When the popover is resizing back to normal size after being 'squashed" toward the top the the screen).

This leaves the UIDatePicker halfway up the popover. I have tried adding a delay, and using an UIKeyboardWillHideNotification, but I cannot get this to work. How can I wait for the popover to finish resizing before I grab the size of the view and perform the animation?

Update 1 I managed to work this out myself, but I'll post the answer here just incase anyone else needs it. Basically I set up a CGRect variable which gets populated with the views bounds when the view loads. Then instead of grabbing the bounds of the view each time I want to animate the UIDatePicker in, I simply use the CGRect variable instead.

Update 2 The above fix works in most cases, but not for all. The problem I am now having is when a new popover is displayed before the keyboard is fully dismissed (i.e. Half way down it's animation out).

This gives bounds at it's current size, before it is then resized to the actual size it needs to be. Also, the popover doesn't seem to resize back to its original size once the keyboard is dismissed. Any ideas folks?

Cocoa-touch xcode ipad uipopovercontroller uikeyboard link|improve this question edited Jun 7 '11 at 16:47 asked Jun 6 '11 at 16:35Peetz707 80% accept rate.

Solved. When keyboard is dismissed in the popover delegate, I check that the popover is being displayed and then reposition it to its original size and location. I have the code if anyone is interested.

Just comment me up.

Yes please! I could really use this code, email me if you would like at lance@optini.com – Lance Jun 27 '11 at 17:18.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions