Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,567
6,073
I'm getting such a headache trying to figure this out...

When I select a text field that's in a scroll view, the keyboard will come up and automatically adjust the scroll view so that it's the proper size to accommodate the keyboard. Additionally, it scrolls to the proper position so that the text view is fully visible. When the keyboard is dismissed, the scroll view will again smoothly go back and fill the screen. This is all handled very smoothly and automatically.

I would like to similarly do this with a button summoning a picker view (as apposed to a text field summoning a keyboard.)

Making the picker slide up isn't an issue... that's a simple matter of making it below the screen, starting an animation, and changing the frame.

What I'm more confused is... what should happen to the scroll view? I've experimented with changing the frame around, but nothing seems to come out quite as smooth as when the keyboard comes out. Suggestions?

Edit: Okay, it seems the secret to this is the property contentOffset. Before changing the frame, it needs to be grabbed and IMMEDIATELY after changing the frame it needs to be restored. After that's restored, it should scroll to the proper spot... with an animation.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.