开发者

Canceling the scrolling animation when keyboard pops up on iphone

I have a UIViewController that contains UITextField. I set the inputAccessory of the textfield to a UIToolbar that I create. My ViewController's view is inside a UIScrollView (To handle the events of keyboard popping up)

Before:

Canceling the scrolling animation when keyboard pops up on iphone

Now, when the keyboard pops up, suddenly my ScrollView is setting it's contentOffset.y to 64 with animation, so part of my view is pushed above the top of the screen:

After:

Canceling the scrolling animation when keyboard pops up on iphone

This is done by the framework because I'm using a toolbar for inputAccessoryView. If i'm dropping the toolbar there is no animation and no content offset.

Is anyone knows how can 开发者_开发知识库I disable this automatic animation and scrolling?

Thank you!


You can use a combination of boolean flags and your UIScrollViewDelegate to prevent the scrolling from taking place. Scroll view delegates can be used to detect when scrolling is taking place, modify the type of scrolling, and also simply prevent it from happening, so your best approach is probably to look into detecting when the keyboard goes up (via a notification or text field delegate, whichever is more appropriate) and using that in combination with your scroll view delegate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜