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:
contentOffset.y
to 64 with animation, so part of my view is pushed above the top of the screen:
After:
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.
精彩评论